#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2014-2021 The PySCF Developers. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors: Qiming Sun <osirpt.sun@gmail.com>
#          Susi Lehtola <susi.lehtola@gmail.com>

'''
XC functional, the interface to libxc
(http://www.tddft.org/programs/octopus/wiki/index.php/Libxc)
'''

import sys
import warnings
import copy
import ctypes
import math
import numpy
from pyscf import lib
from pyscf.dft.xc.utils import remove_dup, format_xc_code
from pyscf import __config__

_itrf = lib.load_library('libxc_itrf')
_itrf.LIBXC_is_lda.restype = ctypes.c_int
_itrf.LIBXC_is_gga.restype = ctypes.c_int
_itrf.LIBXC_is_meta_gga.restype = ctypes.c_int
_itrf.LIBXC_needs_laplacian.restype = ctypes.c_int
_itrf.LIBXC_needs_laplacian.argtypes = [ctypes.c_int]
_itrf.LIBXC_is_hybrid.restype = ctypes.c_int
_itrf.LIBXC_is_cam_rsh.restype = ctypes.c_int
_itrf.LIBXC_max_deriv_order.restype = ctypes.c_int
_itrf.LIBXC_number_of_functionals.restype = ctypes.c_int
_itrf.LIBXC_functional_numbers.argtypes = (numpy.ctypeslib.ndpointer(dtype=numpy.intc, ndim=1, flags=("W", "C", "A")), )
_itrf.LIBXC_functional_name.argtypes = [ctypes.c_int]
_itrf.LIBXC_functional_name.restype = ctypes.c_char_p
_itrf.LIBXC_hybrid_coeff.argtypes = [ctypes.c_int]
_itrf.LIBXC_hybrid_coeff.restype = ctypes.c_double
_itrf.LIBXC_nlc_coeff.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_double)]
_itrf.LIBXC_rsh_coeff.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_double)]

_itrf.LIBXC_version.restype = ctypes.c_char_p
_itrf.LIBXC_reference.restype = ctypes.c_char_p
_itrf.LIBXC_reference_doi.restype = ctypes.c_char_p
_itrf.LIBXC_xc_reference.argtypes = [ctypes.c_int, (ctypes.c_char_p * 8)]

def libxc_version():
    '''Returns the version of libxc'''
    return _itrf.LIBXC_version().decode("UTF-8")

def libxc_reference():
    '''Returns the reference to libxc'''
    return _itrf.LIBXC_reference().decode("UTF-8")

def libxc_reference_doi():
    '''Returns the reference to libxc'''
    return _itrf.LIBXC_reference_doi().decode("UTF-8")

__version__ = libxc_version()
__reference__ = libxc_reference()
__reference_doi__ = libxc_reference_doi()

# Runtime detection of available functionals
dynamic_func = getattr(__config__, 'dft_libxc_dynamic', False)

if dynamic_func:
    def available_libxc_functionals():
        # Number of functionals is
        nfunc = _itrf.LIBXC_number_of_functionals()
        # Get functional numbers
        numbers = numpy.zeros(nfunc, dtype=numpy.intc)
        _itrf.LIBXC_functional_numbers(numbers)
        # Returned array
        return {_itrf.LIBXC_functional_name(x).decode("UTF-8").upper() : x for x in numbers}

    XC = XC_CODES = available_libxc_functionals()
    PROBLEMATIC_XC = dict([])

else:
    # XC dict is generated by
    #import pylibxc
    #for xcname in pylibxc.util.xc_available_functional_names():
    #    f = pylibxc.LibXCFunctional(xcname, 1)
    #    f_id = f.get_number()
    #    ref = f.get_references()
    #    key = f"'{xcname.upper()}'"
    #    print(f"{key:<31s}: {f_id:<3d}, # {ref[0]}")
    XC = XC_CODES = {
        'LDA_C_1D_CSC'                 : 18 , # M. Casula, S. Sorella, and G. Senatore, Phys. Rev. B 74, 245427 (2006)
        'LDA_C_1D_LOOS'                : 26 , # P.-F. Loos, J. Chem. Phys. 138, 064108 (2013)
        'LDA_C_2D_AMGB'                : 15 , # C. Attaccalite, S. Moroni, P. Gori-Giorgi, and G. B. Bachelet, Phys. Rev. Lett. 88, 256601 (2002)
        'LDA_C_2D_PRM'                 : 16 , # S. Pittalis, E. Rasanen, and M. A. L. Marques, Phys. Rev. B 78, 195322 (2008)
        'LDA_C_BR78'                   : 552, # G. B. Jr. and S. M. Rothstein, J. Chem. Phys. 69, 1177 (1978)
        'LDA_C_CHACHIYO'               : 287, # T. Chachiyo, J. Chem. Phys. 145, 021101 (2016)
        'LDA_C_CHACHIYO_MOD'           : 307, # T. Chachiyo and H. Chachiyo, Comput. Theor. Chem. 1172, 112669 (2020)
        'LDA_C_GK72'                   : 578, # R. G. Gordon and Y. S. Kim, J. Chem. Phys. 56, 3122 (1972)
        'LDA_C_GL'                     : 5  , # O. Gunnarsson and B. I. Lundqvist, Phys. Rev. B 13, 4274 (1976)
        'LDA_C_GOMBAS'                 : 24 , # P. Gombas, Fortschr. Phys. 13, 137 (1965)
        'LDA_C_HL'                     : 4  , # L. Hedin and B. I. Lundqvist, J. Phys. C: Solid State Phys. 4, 2064 (1971)
        'LDA_C_KARASIEV'               : 579, # V. V. Karasiev, J. Chem. Phys. 145, 157101 (2016)
        'LDA_C_KARASIEV_MOD'           : 308, # T. Chachiyo and H. Chachiyo, Comput. Theor. Chem. 1172, 112669 (2020)
        'LDA_C_LP96'                   : 289, # S. Liu and R. G. Parr, Phys. Rev. A 53, 2211 (1996)
        'LDA_C_MCWEENY'                : 551, # R. McWeeny, in The New World of Quantum Chemistry, edited by B. Pullman and R. Parr (Reidel, Boston, 1976) pp. 3--31
        'LDA_C_ML1'                    : 22 , # E. I. Proynov and D. R. Salahub, Phys. Rev. B 49, 7874 (1994)
        'LDA_C_ML2'                    : 23 , # E. I. Proynov and D. R. Salahub, Phys. Rev. B 49, 7874 (1994)
        'LDA_C_OB_PW'                  : 14 , # G. Ortiz and P. Ballone, Phys. Rev. B 50, 1391 (1994)
        'LDA_C_OB_PZ'                  : 11 , # G. Ortiz and P. Ballone, Phys. Rev. B 50, 1391 (1994)
        'LDA_C_OW'                     : 574, # P. A. Stewart and P. M. W. Gill, J. Chem. Soc., Faraday Trans. 91, 4337 (1995)
        'LDA_C_OW_LYP'                 : 573, # P. A. Stewart and P. M. W. Gill, J. Chem. Soc., Faraday Trans. 91, 4337 (1995)
        'LDA_C_PK09'                   : 554, # E. Proynov and J. Kong, Phys. Rev. A 79, 014103 (2009)
        'LDA_C_PMGB06'                 : 590, # S. Paziani, S. Moroni, P. Gori-Giorgi, and G. B. Bachelet, Phys. Rev. B 73, 155111 (2006)
        'LDA_C_PW'                     : 12 , # J. P. Perdew and Y. Wang, Phys. Rev. B 45, 13244 (1992)
        'LDA_C_PW_MOD'                 : 13 , # J. P. Perdew and Y. Wang, Phys. Rev. B 45, 13244 (1992), added extra digits to some constants as in the PBE routine (http://dft.rutgers.edu/pubs/PBE.asc)
        'LDA_C_PW_RPA'                 : 25 , # J. P. Perdew and Y. Wang, Phys. Rev. B 45, 13244 (1992)
        'LDA_C_PZ'                     : 9  , # J. P. Perdew and A. Zunger, Phys. Rev. B 23, 5048 (1981)
        'LDA_C_PZ_MOD'                 : 10 , # J. P. Perdew and A. Zunger, Phys. Rev. B 23, 5048 (1981), modified to improve the matching between the low- and high-rs parts
        'LDA_C_RC04'                   : 27 , # S. Ragot and P. Cortona, J. Chem. Phys. 121, 7671 (2004)
        'LDA_C_RPA'                    : 3  , # M. Gell-Mann and K. A. Brueckner, Phys. Rev. 106, 364 (1957)
        'LDA_C_RPW92'                  : 684, # M. Ruggeri, P. L. Rios, and A. Alavi, Phys. Rev. B 98, 161105 (2018)
        'LDA_C_UPW92'                  : 683, # M. Ruggeri, P. L. Rios, and A. Alavi, Phys. Rev. B 98, 161105 (2018)
        'LDA_C_VBH'                    : 17 , # U. von Barth and L. Hedin, J. Phys. C: Solid State Phys. 5, 1629 (1972)
        'LDA_C_VWN'                    : 7  , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_VWN_1'                  : 28 , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_VWN_2'                  : 29 , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_VWN_3'                  : 30 , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_VWN_4'                  : 31 , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_VWN_RPA'                : 8  , # S. H. Vosko, L. Wilk, and M. Nusair, Can. J. Phys. 58, 1200 (1980)
        'LDA_C_WIGNER'                 : 2  , # E. Wigner, Trans. Faraday Soc. 34, 678 (1938)
        'LDA_C_XALPHA'                 : 6  , # J. C. Slater, Phys. Rev. 81, 385 (1951)
        'LDA_K_GDS08_WORKER'           : 100001, # L. M. Ghiringhelli and L. Delle Site, Phys. Rev. B 77, 073104 (2008)
        'LDA_K_LP'                     : 51 , # C. Lee and R. G. Parr, Phys. Rev. A 35, 2377 (1987)
        'LDA_K_LP96'                   : 580, # S. Liu and R. G. Parr, Phys. Rev. A 53, 2211 (1996)
        'LDA_K_TF'                     : 50 , # L. H. Thomas, Math. Proc. Cambridge Philos. Soc. 23, 542 (1927)
        'LDA_K_ZLP'                    : 550, # P. Fuentealba and O. Reyes, Chem. Phys. Lett. 232, 31 (1995)
        'LDA_X'                        : 1  , # P. A. M. Dirac, Math. Proc. Cambridge Philos. Soc. 26, 376 (1930)
        'LDA_X_1D_EXPONENTIAL'         : 600, # N. Helbig, J. I. Fuks, M. Casula, M. J. Verstraete, M. A. L. Marques, I. V. Tokatly, and A. Rubio, Phys. Rev. A 83, 032503 (2011)
        'LDA_X_1D_SOFT'                : 21 , # N. Helbig, J. I. Fuks, M. Casula, M. J. Verstraete, M. A. L. Marques, I. V. Tokatly, and A. Rubio, Phys. Rev. A 83, 032503 (2011)
        'LDA_X_2D'                     : 19 , # P. A. M. Dirac, Math. Proc. Cambridge Philos. Soc. 26, 376 (1930)
        'LDA_X_ERF'                    : 546, # P. M. W. Gill, R. D. Adamson, and J. A. Pople, Mol. Phys. 88, 1005 (1996)
        'LDA_X_RAE'                    : 549, # A. Rae, Chem. Phys. Lett. 18, 574 (1973)
        'LDA_X_REL'                    : 532, # A. K. Rajagopal, J. Phys. C: Solid State Phys. 11, L943 (1978)
        'LDA_X_SLOC'                   : 692, # K. Finzel and A. I. Baranov, Int. J. Quantum Chem. 117, 40 (2017)
        'LDA_XC_1D_EHWLRG_1'           : 536, # M. T. Entwistle, M. J. P. Hodgson, J. Wetherell, B. Longstaff, J. D. Ramsden, and R. W. Godby, Phys. Rev. B 94, 205134 (2016)
        'LDA_XC_1D_EHWLRG_2'           : 537, # M. T. Entwistle, M. J. P. Hodgson, J. Wetherell, B. Longstaff, J. D. Ramsden, and R. W. Godby, Phys. Rev. B 94, 205134 (2016)
        'LDA_XC_1D_EHWLRG_3'           : 538, # M. T. Entwistle, M. J. P. Hodgson, J. Wetherell, B. Longstaff, J. D. Ramsden, and R. W. Godby, Phys. Rev. B 94, 205134 (2016)
        'LDA_XC_BN05'                  : 588, # R. Baer and D. Neuhauser, Phys. Rev. Lett. 94, 043002 (2005)
        'LDA_XC_GDSMFB'                : 577, # S. Groth, T. Dornheim, T. Sjostrom, F. D. Malone, W. M. C. Foulkes, and M. Bonitz, Phys. Rev. Lett. 119, 135001 (2017)
        'LDA_XC_KSDT'                  : 259, # V. V. Karasiev, T. Sjostrom, J. Dufty, and S. B. Trickey, Phys. Rev. Lett. 112, 076403 (2014)
        'LDA_XC_LP_A'                  : 547, # C. Lee and R. G. Parr, Phys. Rev. A 42, 193 (1990)
        'LDA_XC_LP_B'                  : 548, # C. Lee and R. G. Parr, Phys. Rev. A 42, 193 (1990)
        'LDA_XC_TETER93'               : 20 , # S. Goedecker, M. Teter, and J. Hutter, Phys. Rev. B 54, 1703 (1996)
        'LDA_XC_TIH'                   : 599, # D. J. Tozer, V. E. Ingamells, and N. C. Handy, J. Chem. Phys. 105, 9200 (1996)
        'LDA_XC_ZLP'                   : 43 , # Q. Zhao, M. Levy, and R. G. Parr, Phys. Rev. A 47, 918 (1993)
        'HYB_LDA_XC_CAM_LDA0'          : 178, # M. A. Mosquera, C. H. Borca, M. A. Ratner, and G. C. Schatz, J. Phys. Chem. A 120, 1605 (2016)
        'HYB_LDA_XC_LDA0'              : 177, # P. Rinke, A. Schleife, E. Kioupakis, A. Janotti, C. Rodl, F. Bechstedt, M. Scheffler, and C. G. Van de Walle, Phys. Rev. Lett. 108, 126404 (2012)
        'GGA_C_ACGGA'                  : 39 , # A. Cancio, G. P. Chen, B. T. Krull, and K. Burke, J. Chem. Phys. 149, 084116 (2018)
        'GGA_C_ACGGAP'                 : 176, # A. Cancio, G. P. Chen, B. T. Krull, and K. Burke, J. Chem. Phys. 149, 084116 (2018)
        'GGA_C_AM05'                   : 135, # R. Armiento and A. E. Mattsson, Phys. Rev. B 72, 085108 (2005)
        'GGA_C_APBE'                   : 186, # L. A. Constantin, E. Fabiano, S. Laricchia, and F. Della Sala, Phys. Rev. Lett. 106, 186406 (2011)
        'GGA_C_BMK'                    : 280, # A. D. Boese and J. M. L. Martin, J. Chem. Phys. 121, 3405 (2004)
        'GGA_C_CCDF'                   : 313, # J. T. Margraf, C. Kunkel, and K. Reuter, J. Chem. Phys. 150, 244116 (2019)
        'GGA_C_CHACHIYO'               : 309, # T. Chachiyo and H. Chachiyo, Comput. Theor. Chem. 1172, 112669 (2020)
        'GGA_C_CS1'                    : 565, # N. C. Handy and A. J. Cohen, J. Chem. Phys. 116, 5411 (2002)
        'GGA_C_FT97'                   : 88 , # M. Filatov and W. Thiel, Int. J. Quantum Chem. 62, 603 (1997)
        'GGA_C_GAM'                    : 33 , # H. S. Yu, W. Zhang, P. Verma, X. He, and D. G. Truhlar, Phys. Chem. Chem. Phys. 17, 12146 (2015)
        'GGA_C_GAPC'                   : 555, # E. Fabiano, P. E. Trevisanutto, A. Terentjevs, and L. A. Constantin, J. Chem. Theory Comput. 10, 2016 (2014)
        'GGA_C_GAPLOC'                 : 556, # E. Fabiano, P. E. Trevisanutto, A. Terentjevs, and L. A. Constantin, J. Chem. Theory Comput. 10, 2016 (2014)
        'GGA_C_HCTH_A'                 : 97 , # F. A. Hamprecht, A. J. Cohen, D. J. Tozer, and N. C. Handy, J. Chem. Phys. 109, 6264 (1998)
        'GGA_C_HYB_TAU_HCTH'           : 283, # A. D. Boese and N. C. Handy, J. Chem. Phys. 116, 9559 (2002)
        'GGA_C_LM'                     : 137, # D. C. Langreth and M. J. Mehl, Phys. Rev. Lett. 47, 446 (1981)
        'GGA_C_LYP'                    : 131, # C. Lee, W. Yang, and R. G. Parr, Phys. Rev. B 37, 785 (1988)
        'GGA_C_MGGAC'                  : 712, # B. Patra, S. Jana, L. A. Constantin, and P. Samal, Phys. Rev. B 100, 155140 (2019)
        'GGA_C_N12'                    : 80 , # R. Peverati and D. G. Truhlar, J. Chem. Theory Comput. 8, 2310 (2012)
        'GGA_C_N12_SX'                 : 79 , # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 16187 (2012)
        'GGA_C_OP_B88'                 : 87 , # T. Tsuneda, T. Suzumura, and K. Hirao, J. Chem. Phys. 110, 10664 (1999)
        'GGA_C_OP_G96'                 : 85 , # T. Tsuneda, T. Suzumura, and K. Hirao, J. Chem. Phys. 110, 10664 (1999)
        'GGA_C_OP_PBE'                 : 86 , # T. Tsuneda, T. Suzumura, and K. Hirao, J. Chem. Phys. 110, 10664 (1999)
        'GGA_C_OP_PW91'                : 262, # T. Tsuneda, T. Suzumura, and K. Hirao, J. Chem. Phys. 110, 10664 (1999)
        'GGA_C_OP_XALPHA'              : 84 , # T. Tsuneda, T. Suzumura, and K. Hirao, J. Chem. Phys. 110, 10664 (1999)
        'GGA_C_OPTC'                   : 200, # A. J. Cohen and N. C. Handy, Mol. Phys. 99, 607 (2001)
        'GGA_C_P86'                    : 132, # J. P. Perdew, Phys. Rev. B 33, 8822 (1986)
        'GGA_C_P86_FT'                 : 217, # J. P. Perdew, Phys. Rev. B 33, 8822 (1986)
        'GGA_C_P86VWN'                 : 252, # J. P. Perdew, Phys. Rev. B 33, 8822 (1986)
        'GGA_C_P86VWN_FT'              : 253, # J. P. Perdew, Phys. Rev. B 33, 8822 (1986)
        'GGA_C_PBE'                    : 130, # J. P. Perdew, K. Burke, and M. Ernzerhof, Phys. Rev. Lett. 77, 3865 (1996)
        'GGA_C_PBE_JRGX'               : 138, # L. S. Pedroza, A. J. R. da Silva, and K. Capelle, Phys. Rev. B 79, 201106 (2009)
        'GGA_C_PBE_MOL'                : 272, # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'GGA_C_PBE_SOL'                : 133, # J. P. Perdew, A. Ruzsinszky, G. I. Csonka, O. A. Vydrov, G. E. Scuseria, L. A. Constantin, X. Zhou, and K. Burke, Phys. Rev. Lett. 100, 136406 (2008)
        'GGA_C_PBE_VWN'                : 216, # E. Kraisler, G. Makov, and I. Kelson, Phys. Rev. A 82, 042516 (2010)
        'GGA_C_PBEFE'                  : 258, # R. Sarmiento-Perez, S. Botti, and M. A. L. Marques, J. Chem. Theory Comput. 11, 3844 (2015)
        'GGA_C_PBEINT'                 : 62 , # E. Fabiano, L. A. Constantin, and F. Della Sala, Phys. Rev. B 82, 113104 (2010)
        'GGA_C_PBELOC'                 : 246, # L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. B 86, 035130 (2012)
        'GGA_C_PW91'                   : 134, # J. P. Perdew, in Proceedings of the 75. WE-Heraeus-Seminar and 21st Annual International Symposium on Electronic Structure of Solids, edited by P. Ziesche and H. Eschrig (Akademie Verlag, Berlin, 1991) p. 11
        'GGA_C_Q2D'                    : 47 , # L. Chiodo, L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. Lett. 108, 126402 (2012)
        'GGA_C_REGTPSS'                : 83 , # J. P. Perdew, A. Ruzsinszky, G. I. Csonka, L. A. Constantin, and J. Sun, Phys. Rev. Lett. 103, 026403 (2009)
        'GGA_C_REVTCA'                 : 99 , # V. Tognetti, P. Cortona, and C. Adamo, Chem. Phys. Lett. 460, 536 (2008)
        'GGA_C_RGE2'                   : 143, # A. Ruzsinszky, G. I. Csonka, and G. E. Scuseria, J. Chem. Theory Comput. 5, 763 (2009)
        'GGA_C_SCAN_E0'                : 553, # J. Sun, A. Ruzsinszky, and J. P. Perdew, Phys. Rev. Lett. 115, 036402 (2015)
        'GGA_C_SG4'                    : 534, # L. A. Constantin, A. Terentjevs, F. Della Sala, P. Cortona, and E. Fabiano, Phys. Rev. B 93, 045126 (2016)
        'GGA_C_SOGGA11'                : 152, # R. Peverati, Y. Zhao, and D. G. Truhlar, J. Phys. Chem. Lett. 2, 1991 (2011)
        'GGA_C_SOGGA11_X'              : 159, # R. Peverati and D. G. Truhlar, J. Chem. Phys. 135, 191102 (2011)
        'GGA_C_SPBE'                   : 89 , # M. Swart, M. Sola, and F. M. Bickelhaupt, J. Chem. Phys. 131, 094103 (2009)
        'GGA_C_TAU_HCTH'               : 281, # A. D. Boese and N. C. Handy, J. Chem. Phys. 116, 9559 (2002)
        'GGA_C_TCA'                    : 100, # V. Tognetti, P. Cortona, and C. Adamo, J. Chem. Phys. 128, 034101 (2008)
        'GGA_C_TM_LYP'                 : 559, # A. J. Thakkar and S. P. McCarthy, J. Chem. Phys. 131, 134109 (2009)
        'GGA_C_TM_PBE'                 : 560, # A. J. Thakkar and S. P. McCarthy, J. Chem. Phys. 131, 134109 (2009)
        'GGA_C_W94'                    : 561, # L. C. Wilson, Chem. Phys. 181, 337 (1994)
        'GGA_C_WI'                     : 148, # L. C. Wilson and S. Ivanov, Int. J. Quantum Chem. 69, 523 (1998)
        'GGA_C_WI0'                    : 153, # L. C. Wilson and S. Ivanov, Int. J. Quantum Chem. 69, 523 (1998)
        'GGA_C_WL'                     : 147, # L. C. Wilson and M. Levy, Phys. Rev. B 41, 12930 (1990)
        'GGA_C_XPBE'                   : 136, # X. Xu and W. A. Goddard, J. Chem. Phys. 121, 4068 (2004)
        'GGA_C_ZPBEINT'                : 61 , # L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. B 84, 233103 (2011)
        'GGA_C_ZPBESOL'                : 63 , # L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. B 84, 233103 (2011)
        'GGA_C_ZVPBEINT'               : 557, # L. A. Constantin, E. Fabiano, and F. D. Sala, J. Chem. Phys. 137, 194105 (2012)
        'GGA_C_ZVPBELOC'               : 606, # E. Fabiano, L. A. Constantin, P. Cortona, and F. Della Sala, J. Chem. Theory Comput. 11, 122 (2015)
        'GGA_C_ZVPBESOL'               : 558, # L. A. Constantin, E. Fabiano, and F. D. Sala, J. Chem. Phys. 137, 194105 (2012)
        'GGA_K_ABSP1'                  : 506, # P. K. Acharya, L. J. Bartolotti, S. B. Sears, and R. G. Parr, Proc. Natl. Acad. Sci. U. S. A. 77, 6978 (1980)
        'GGA_K_ABSP2'                  : 507, # P. K. Acharya, L. J. Bartolotti, S. B. Sears, and R. G. Parr, Proc. Natl. Acad. Sci. U. S. A. 77, 6978 (1980)
        'GGA_K_ABSP3'                  : 277, # P. K. Acharya, L. J. Bartolotti, S. B. Sears, and R. G. Parr, Proc. Natl. Acad. Sci. U. S. A. 77, 6978 (1980)
        'GGA_K_ABSP4'                  : 278, # P. K. Acharya, L. J. Bartolotti, S. B. Sears, and R. G. Parr, Proc. Natl. Acad. Sci. U. S. A. 77, 6978 (1980)
        'GGA_K_APBE'                   : 185, # L. A. Constantin, E. Fabiano, S. Laricchia, and F. Della Sala, Phys. Rev. Lett. 106, 186406 (2011)
        'GGA_K_APBEINT'                : 54 , # S. Laricchia, E. Fabiano, L. A. Constantin, and F. Della Sala, J. Chem. Theory Comput. 7, 2439 (2011)
        'GGA_K_BALTIN'                 : 504, # R. Baltin, Z. Naturforsch. A 27, 1176 (1972)
        'GGA_K_DK'                     : 516, # A. E. DePristo and J. D. Kress, Phys. Rev. A 35, 438 (1987)
        'GGA_K_ERNZERHOF'              : 520, # M. Ernzerhof, J. Mol. Struct.: THEOCHEM 501--502, 59 (2000)
        'GGA_K_EXP4'                   : 597, # V. V. Karasiev, S. B. Trickey, and F. E. Harris, J. Comput.-Aided Mater. Des. 13, 111 (2006)
        'GGA_K_FR_B88'                 : 514, # P. Fuentealba and O. Reyes, Chem. Phys. Lett. 232, 31 (1995)
        'GGA_K_FR_PW86'                : 515, # P. Fuentealba and O. Reyes, Chem. Phys. Lett. 232, 31 (1995)
        'GGA_K_GDS08'                  : 591, # L. M. Ghiringhelli and L. Delle Site, Phys. Rev. B 77, 073104 (2008)
        'GGA_K_GE2'                    : 501, # A. S. Kompaneets and E. S. Pavlovskii, Zh. Eksp. Teor. Fiz. 31, 427 (1956), [J. Exp. Theor. Phys. 4, 328 (1957)]
        'GGA_K_GHDS10'                 : 592, # L. M. Ghiringhelli, I. P. Hamilton, and L. D. Site, J. Chem. Phys. 132, 014106 (2010)
        'GGA_K_GHDS10R'                : 593, # S. B. Trickey, V. V. Karasiev, and A. Vela, Phys. Rev. B 84, 075146 (2011)
        'GGA_K_GOLDEN'                 : 502, # S. Golden, Phys. Rev. 105, 604 (1957)
        'GGA_K_GP85'                   : 510, # S. K. Ghosh and R. G. Parr, J. Chem. Phys. 82, 3307 (1985)
        'GGA_K_GR'                     : 508, # J. L. Gazquez and J. Robles, J. Chem. Phys. 76, 1467 (1982)
        'GGA_K_LC94'                   : 521, # A. Lembarki and H. Chermette, Phys. Rev. A 50, 5328 (1994)
        'GGA_K_LGAP'                   : 620, # L. A. Constantin, E. Fabiano, S. Smiga, and F. Della Sala, Phys. Rev. B 95, 115153 (2017)
        'GGA_K_LGAP_GE'                : 633, # L. A. Constantin, E. Fabiano, S. Smiga, and F. Della Sala, Phys. Rev. B 95, 115153 (2017)
        'GGA_K_LIEB'                   : 505, # E. H. Lieb, Rev. Mod. Phys. 53, 603 (1981)
        'GGA_K_LKT'                    : 613, # K. Luo, V. V. Karasiev, and S. B. Trickey, Phys. Rev. B 98, 041111 (2018)
        'GGA_K_LLP'                    : 522, # H. Lee, C. Lee, and R. G. Parr, Phys. Rev. A 44, 768 (1991)
        'GGA_K_LUDENA'                 : 509, # E. V. Ludena, in Cond. Matt. Theor., Vol. 1, edited by F. B. Malik (Plenum, New York, 1986) p. 183
        'GGA_K_MEYER'                  : 57 , # A. Meyer, G. C. Wang, and W. H. Young, Z. Naturforsch. A 31, 898 (1976)
        'GGA_K_OL1'                    : 512, # H. Ou-Yang and M. Levy, Int. J. Quantum Chem. 40, 379 (1991)
        'GGA_K_OL2'                    : 513, # H. Ou-Yang and M. Levy, Int. J. Quantum Chem. 40, 379 (1991)
        'GGA_K_PBE2'                   : 616, # V. V. Karasiev, S. B. Trickey, and F. E. Harris, J. Comput.-Aided Mater. Des. 13, 111 (2006)
        'GGA_K_PBE3'                   : 595, # V. V. Karasiev, S. B. Trickey, and F. E. Harris, J. Comput.-Aided Mater. Des. 13, 111 (2006)
        'GGA_K_PBE4'                   : 596, # V. V. Karasiev, S. B. Trickey, and F. E. Harris, J. Comput.-Aided Mater. Des. 13, 111 (2006)
        'GGA_K_PEARSON'                : 511, # D. J. Lacks and R. G. Gordon, J. Chem. Phys. 100, 4446 (1994)
        'GGA_K_PERDEW'                 : 517, # J. P. Perdew, Phys. Lett. A 165, 79 (1992)
        'GGA_K_PG1'                    : 219, # L. A. Constantin, E. Fabiano, and F. Della Sala, J. Phys. Chem. Lett. 9, 4385 (2018), pMID: 30019904
        'GGA_K_RATIONAL_P'             : 218, # J. Lehtomaki and O. Lopez-Acevedo, Phys. Rev. B 100, 165111 (2019)
        'GGA_K_REVAPBE'                : 55 , # L. A. Constantin, E. Fabiano, S. Laricchia, and F. Della Sala, Phys. Rev. Lett. 106, 186406 (2011)
        'GGA_K_REVAPBEINT'             : 53 , # S. Laricchia, E. Fabiano, L. A. Constantin, and F. Della Sala, J. Chem. Theory Comput. 7, 2439 (2011)
        'GGA_K_TFVW'                   : 52 , # C. F. von Weizsacker, Z. Phys. 96, 431 (1935)
        'GGA_K_TFVW_OPT'               : 635, # L. A. Espinosa Leal, A. Karpenko, M. A. Caro, and O. Lopez-Acevedo, Phys. Chem. Chem. Phys. 17, 31463 (2015)
        'GGA_K_THAKKAR'                : 523, # A. J. Thakkar, Phys. Rev. A 46, 6920 (1992)
        'GGA_K_TKVLN'                  : 594, # S. B. Trickey, V. V. Karasiev, and A. Vela, Phys. Rev. B 84, 075146 (2011)
        'GGA_K_TW1'                    : 187, # F. Tran and T. A. Wesolowski, Int. J. Quantum Chem. 89, 441 (2002)
        'GGA_K_TW2'                    : 188, # F. Tran and T. A. Wesolowski, Int. J. Quantum Chem. 89, 441 (2002)
        'GGA_K_TW3'                    : 189, # F. Tran and T. A. Wesolowski, Int. J. Quantum Chem. 89, 441 (2002)
        'GGA_K_TW4'                    : 190, # F. Tran and T. A. Wesolowski, Int. J. Quantum Chem. 89, 441 (2002)
        'GGA_K_VJKS'                   : 519, # L. Vitos, B. Johansson, J. Kollar, and H. L. Skriver, Phys. Rev. A 61, 052511 (2000)
        'GGA_K_VSK'                    : 518, # L. Vitos, H. L. Skriver, and J. Kollar, Phys. Rev. B 57, 12611 (1998)
        'GGA_K_VT84F'                  : 619, # V. V. Karasiev, D. Chakraborty, O. A. Shukruto, and S. B. Trickey, Phys. Rev. B 88, 161108 (2013)
        'GGA_K_VW'                     : 500, # C. F. von Weizsacker, Z. Phys. 96, 431 (1935)
        'GGA_K_YT65'                   : 503, # K. Yonei and Y. Tomishima, J. Phys. Soc. Jpn. 20, 1051 (1965)
        'GGA_X_2D_B86'                 : 128, # J. G. Vilhena, E. Rasanen, M. A. L. Marques, and S. Pittalis, J. Chem. Theory Comput. 10, 1837 (2014)
        'GGA_X_2D_B86_MGC'             : 124, # S. Pittalis, E. Rasanen, J. G. Vilhena, and M. A. L. Marques, Phys. Rev. A 79, 012503 (2009)
        'GGA_X_2D_B88'                 : 127, # J. G. Vilhena, E. Rasanen, M. A. L. Marques, and S. Pittalis, J. Chem. Theory Comput. 10, 1837 (2014)
        'GGA_X_2D_PBE'                 : 129, # J. G. Vilhena, E. Rasanen, M. A. L. Marques, and S. Pittalis, J. Chem. Theory Comput. 10, 1837 (2014)
        'GGA_X_AIRY'                   : 192, # L. A. Constantin, A. Ruzsinszky, and J. P. Perdew, Phys. Rev. B 80, 035125 (2009)
        'GGA_X_AK13'                   : 56 , # R. Armiento and S. Kummel, Phys. Rev. Lett. 111, 036402 (2013)
        'GGA_X_AM05'                   : 120, # R. Armiento and A. E. Mattsson, Phys. Rev. B 72, 085108 (2005)
        'GGA_X_APBE'                   : 184, # L. A. Constantin, E. Fabiano, S. Laricchia, and F. Della Sala, Phys. Rev. Lett. 106, 186406 (2011)
        'GGA_X_B86'                    : 103, # A. D. Becke, J. Chem. Phys. 84, 4524 (1986)
        'GGA_X_B86_MGC'                : 105, # A. D. Becke, J. Chem. Phys. 84, 4524 (1986)
        'GGA_X_B86_R'                  : 41 , # I. Hamada, Phys. Rev. B 89, 121103 (2014)
        'GGA_X_B88'                    : 106, # A. D. Becke, Phys. Rev. A 38, 3098 (1988)
        'GGA_X_B88_6311G'              : 179, # J. M. Ugalde, C. Sarasola, and M. Aguado, J. Phys. B: At., Mol. Opt. Phys. 27, 423 (1994)
        'GGA_X_B88M'                   : 570, # E. Proynov, H. Chermette, and D. R. Salahub, J. Chem. Phys. 113, 10013 (2000)
        'GGA_X_BAYESIAN'               : 125, # J. J. Mortensen, K. Kaasbjerg, S. L. Frederiksen, J. K. Norskov, J. P. Sethna, and K. W. Jacobsen, Phys. Rev. Lett. 95, 216401 (2005)
        'GGA_X_BCGP'                   : 38 , # K. Burke, A. Cancio, T. Gould, and S. Pittalis, ArXiv e-prints (2014), arXiv:1409.4834 [cond-mat.mtrl-sci]
        'GGA_X_BEEFVDW'                : 285, # J. Wellendorff, K. T. Lundgaard, A. Mogelhoj, V. Petzold, D. D. Landis, J. K. Norskov, T. Bligaard, and K. W. Jacobsen, Phys. Rev. B 85, 235149 (2012)
        'GGA_X_BPCCAC'                 : 98 , # E. Bremond, D. Pilard, I. Ciofini, H. Chermette, C. Adamo, and P. Cortona, Theor. Chem. Acc. 131, 1184 (2012)
        'GGA_X_C09X'                   : 158, # V. R. Cooper, Phys. Rev. B 81, 161104 (2010)
        'GGA_X_CAP'                    : 270, # J. Carmona-Espindola, J. L. Gazquez, A. Vela, and S. B. Trickey, J. Chem. Phys. 142, 054105 (2015)
        'GGA_X_CHACHIYO'               : 298, # T. Chachiyo and H. Chachiyo, Molecules 25, 3485 (2020)
        'GGA_X_DK87_R1'                : 111, # A. E. DePristo and J. D. Kress, J. Chem. Phys. 86, 1425 (1987)
        'GGA_X_DK87_R2'                : 112, # A. E. DePristo and J. D. Kress, J. Chem. Phys. 86, 1425 (1987)
        'GGA_X_EB88'                   : 271, # P. Elliott and K. Burke, Can. J. Chem. 87, 1485 (2009)
        'GGA_X_ECMV92'                 : 215, # E. Engel, J. A. Chevary, L. D. Macdonald, and S. H. Vosko, Z. Phys. D: At., Mol. Clusters 23, 7 (1992)
        'GGA_X_EV93'                   : 35 , # E. Engel and S. H. Vosko, Phys. Rev. B 47, 13164 (1993)
        'GGA_X_FD_LB94'                : 604, # A. P. Gaiduk and V. N. Staroverov, Phys. Rev. A 83, 012509 (2011)
        'GGA_X_FD_REVLB94'             : 605, # A. P. Gaiduk and V. N. Staroverov, Phys. Rev. A 83, 012509 (2011)
        'GGA_X_FT97_A'                 : 114, # M. Filatov and W. Thiel, Mol. Phys. 91, 847 (1997)
        'GGA_X_FT97_B'                 : 115, # M. Filatov and W. Thiel, Mol. Phys. 91, 847 (1997)
        'GGA_X_G96'                    : 107, # P. M. W. Gill, Mol. Phys. 89, 433 (1996)
        'GGA_X_GAM'                    : 32 , # H. S. Yu, W. Zhang, P. Verma, X. He, and D. G. Truhlar, Phys. Chem. Chem. Phys. 17, 12146 (2015)
        'GGA_X_GG99'                   : 535, # A. T. Gilbert and P. M. Gill, Chem. Phys. Lett. 312, 511 (1999)
        'GGA_X_HCTH_A'                 : 34 , # F. A. Hamprecht, A. J. Cohen, D. J. Tozer, and N. C. Handy, J. Chem. Phys. 109, 6264 (1998)
        'GGA_X_HERMAN'                 : 104, # F. Herman, J. P. V. Dyke, and I. B. Ortenburger, Phys. Rev. Lett. 22, 807 (1969)
        'GGA_X_HJS_B88'                : 527, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'GGA_X_HJS_B88_V2'             : 46 , # E. Weintraub, T. M. Henderson, and G. E. Scuseria, J. Chem. Theory Comput. 5, 754 (2009)
        'GGA_X_HJS_B97X'               : 528, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'GGA_X_HJS_PBE'                : 525, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'GGA_X_HJS_PBE_SOL'            : 526, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'GGA_X_HTBS'                   : 191, # P. Haas, F. Tran, P. Blaha, and K. Schwarz, Phys. Rev. B 83, 205117 (2011)
        'GGA_X_ITYH'                   : 529, # H. Iikura, T. Tsuneda, T. Yanai, and K. Hirao, J. Chem. Phys. 115, 3540 (2001)
        'GGA_X_ITYH_OPTX'              : 622, # N. C. Handy and A. J. Cohen, Mol. Phys. 99, 403 (2001)
        'GGA_X_ITYH_PBE'               : 623, # J. P. Perdew, K. Burke, and M. Ernzerhof, Phys. Rev. Lett. 77, 3865 (1996)
        'GGA_X_KGG99'                  : 544, # A. T. Gilbert and P. M. Gill, Chem. Phys. Lett. 312, 511 (1999)
        'GGA_X_KT1'                    : 145, # T. W. Keal and D. J. Tozer, J. Chem. Phys. 119, 3015 (2003)
        'GGA_X_LAG'                    : 193, # L. Vitos, B. Johansson, J. Kollar, and H. L. Skriver, Phys. Rev. B 62, 10046 (2000)
        'GGA_X_LAMBDA_CH_N'            : 44 , # M. M. Odashima, K. Capelle, and S. B. Trickey, J. Chem. Theory Comput. 5, 798 (2009)
        'GGA_X_LAMBDA_LO_N'            : 45 , # M. M. Odashima, K. Capelle, and S. B. Trickey, J. Chem. Theory Comput. 5, 798 (2009)
        'GGA_X_LAMBDA_OC2_N'           : 40 , # M. M. Odashima, K. Capelle, and S. B. Trickey, J. Chem. Theory Comput. 5, 798 (2009)
        'GGA_X_LB'                     : 160, # R. van Leeuwen and E. J. Baerends, Phys. Rev. A 49, 2421 (1994)
        'GGA_X_LBM'                    : 182, # P. R. T. Schipper, O. V. Gritsenko, S. J. A. van Gisbergen, and E. J. Baerends, J. Chem. Phys. 112, 1344 (2000)
        'GGA_X_LG93'                   : 113, # D. J. Lacks and R. G. Gordon, Phys. Rev. A 47, 4681 (1993)
        'GGA_X_LSPBE'                  : 168, # J. C. Pacheco-Kato, J. M. del Campo, J. L. Gazquez, S. Trickey, and A. Vela, Chem. Phys. Lett. 651, 268 (2016)
        'GGA_X_LSRPBE'                 : 169, # J. C. Pacheco-Kato, J. M. del Campo, J. L. Gazquez, S. Trickey, and A. Vela, Chem. Phys. Lett. 651, 268 (2016)
        'GGA_X_LV_RPW86'               : 58 , # K. Berland and P. Hyldgaard, Phys. Rev. B 89, 035412 (2014)
        'GGA_X_MB88'                   : 149, # V. Tognetti and C. Adamo, J. Phys. Chem. A 113, 14415 (2009)
        'GGA_X_MPBE'                   : 122, # C. Adamo and V. Barone, J. Chem. Phys. 116, 5933 (2002)
        'GGA_X_MPW91'                  : 119, # C. Adamo and V. Barone, J. Chem. Phys. 108, 664 (1998)
        'GGA_X_N12'                    : 82 , # R. Peverati and D. G. Truhlar, J. Chem. Theory Comput. 8, 2310 (2012)
        'GGA_X_NCAP'                   : 180, # J. Carmona-Espindola, J. L. Gazquez, A. Vela, and S. B. Trickey, J. Chem. Theory Comput. 15, 303 (2019)
        'GGA_X_OL2'                    : 183, # P. Fuentealba and O. Reyes, Chem. Phys. Lett. 232, 31 (1995)
        'GGA_X_OPTB86B_VDW'            : 171, # J. Klimes, D. R. Bowler, and A. Michaelides, Phys. Rev. B 83, 195131 (2011)
        'GGA_X_OPTB88_VDW'             : 139, # J. Klimes, D. R. Bowler, and A. Michaelides, J. Phys.: Condens. Matter 22, 022201 (2010)
        'GGA_X_OPTPBE_VDW'             : 141, # J. Klimes, D. R. Bowler, and A. Michaelides, J. Phys.: Condens. Matter 22, 022201 (2010)
        'GGA_X_OPTX'                   : 110, # N. C. Handy and A. J. Cohen, Mol. Phys. 99, 403 (2001)
        'GGA_X_PBE'                    : 101, # J. P. Perdew, K. Burke, and M. Ernzerhof, Phys. Rev. Lett. 77, 3865 (1996)
        'GGA_X_PBE_JSJR'               : 126, # L. S. Pedroza, A. J. R. da Silva, and K. Capelle, Phys. Rev. B 79, 201106 (2009)
        'GGA_X_PBE_MOL'                : 49 , # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'GGA_X_PBE_R'                  : 102, # Y. Zhang and W. Yang, Phys. Rev. Lett. 80, 890 (1998)
        'GGA_X_PBE_SOL'                : 116, # J. P. Perdew, A. Ruzsinszky, G. I. Csonka, O. A. Vydrov, G. E. Scuseria, L. A. Constantin, X. Zhou, and K. Burke, Phys. Rev. Lett. 100, 136406 (2008)
        'GGA_X_PBE_TCA'                : 59 , # V. Tognetti, P. Cortona, and C. Adamo, Chem. Phys. Lett. 460, 536 (2008)
        'GGA_X_PBEA'                   : 121, # G. K. H. Madsen, Phys. Rev. B 75, 195108 (2007)
        'GGA_X_PBEFE'                  : 265, # R. Sarmiento-Perez, S. Botti, and M. A. L. Marques, J. Chem. Theory Comput. 11, 3844 (2015)
        'GGA_X_PBEINT'                 : 60 , # E. Fabiano, L. A. Constantin, and F. Della Sala, Phys. Rev. B 82, 113104 (2010)
        'GGA_X_PBEK1_VDW'              : 140, # J. Klimes, D. R. Bowler, and A. Michaelides, J. Phys.: Condens. Matter 22, 022201 (2010)
        'GGA_X_PBEPOW'                 : 539, # Eric Bremond, J. Chem. Phys. 145, 244102 (2016)
        'GGA_X_PBETRANS'               : 291, # Eric Bremond, I. Ciofini, and C. Adamo, Mol. Phys. 114, 1059 (2016)
        'GGA_X_PW86'                   : 108, # J. P. Perdew and W. Yue, Phys. Rev. B 33, 8800 (1986)
        'GGA_X_PW91'                   : 109, # J. P. Perdew, in Proceedings of the 75. WE-Heraeus-Seminar and 21st Annual International Symposium on Electronic Structure of Solids, edited by P. Ziesche and H. Eschrig (Akademie Verlag, Berlin, 1991) p. 11
        'GGA_X_PW91_MOD'               : 316, # J. P. Perdew, in Proceedings of the 75. WE-Heraeus-Seminar and 21st Annual International Symposium on Electronic Structure of Solids, edited by P. Ziesche and H. Eschrig (Akademie Verlag, Berlin, 1991) p. 11
        'GGA_X_Q2D'                    : 48 , # L. Chiodo, L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. Lett. 108, 126402 (2012)
        'GGA_X_REVSSB_D'               : 312, # M. Swart, M. Sola, and F. M. Bickelhaupt, J. Comput. Chem. 32, 1117 (2011)
        'GGA_X_RGE2'                   : 142, # A. Ruzsinszky, G. I. Csonka, and G. E. Scuseria, J. Chem. Theory Comput. 5, 763 (2009)
        'GGA_X_RPBE'                   : 117, # B. Hammer, L. B. Hansen, and J. K. Norskov, Phys. Rev. B 59, 7413 (1999)
        'GGA_X_RPW86'                  : 144, # E. D. Murray, K. Lee, and D. C. Langreth, J. Chem. Theory Comput. 5, 2754 (2009)
        'GGA_X_S12G'                   : 495, # M. Swart, Chem. Phys. Lett. 580, 166 (2013)
        'GGA_X_SFAT'                   : 530, # A. Savin and H.-J. Flad, Int. J. Quantum Chem. 56, 327 (1995)
        'GGA_X_SFAT_PBE'               : 601, # A. Savin and H.-J. Flad, Int. J. Quantum Chem. 56, 327 (1995)
        'GGA_X_SG4'                    : 533, # L. A. Constantin, A. Terentjevs, F. Della Sala, P. Cortona, and E. Fabiano, Phys. Rev. B 93, 045126 (2016)
        'GGA_X_SOGGA'                  : 150, # Y. Zhao and D. G. Truhlar, J. Chem. Phys. 128, 184109 (2008)
        'GGA_X_SOGGA11'                : 151, # R. Peverati, Y. Zhao, and D. G. Truhlar, J. Phys. Chem. Lett. 2, 1991 (2011)
        'GGA_X_SSB'                    : 91 , # M. Swart, M. Sola, and F. M. Bickelhaupt, J. Chem. Phys. 131, 094103 (2009)
        'GGA_X_SSB_D'                  : 92 , # M. Swart, M. Sola, and F. M. Bickelhaupt, J. Chem. Phys. 131, 094103 (2009)
        'GGA_X_SSB_SW'                 : 90 , # M. Swart, M. Sola, and F. M. Bickelhaupt, J. Comput. Methods Sci. Eng. 9, 69 (2009)
        'GGA_X_VMT84_GE'               : 68 , # A. Vela, J. C. Pacheco-Kato, J. L. Gazquez, J. M. del Campo, and S. B. Trickey, J. Chem. Phys. 136, 144115 (2012)
        'GGA_X_VMT84_PBE'              : 69 , # A. Vela, J. C. Pacheco-Kato, J. L. Gazquez, J. M. del Campo, and S. B. Trickey, J. Chem. Phys. 136, 144115 (2012)
        'GGA_X_VMT_GE'                 : 70 , # A. Vela, V. Medel, and S. B. Trickey, J. Chem. Phys. 130, 244103 (2009)
        'GGA_X_VMT_PBE'                : 71 , # A. Vela, V. Medel, and S. B. Trickey, J. Chem. Phys. 130, 244103 (2009)
        'GGA_X_WC'                     : 118, # Z. Wu and R. E. Cohen, Phys. Rev. B 73, 235116 (2006)
        'GGA_X_WPBEH'                  : 524, # J. Heyd, G. E. Scuseria, and M. Ernzerhof, J. Chem. Phys. 118, 8207 (2003)
        'GGA_X_XPBE'                   : 123, # X. Xu and W. A. Goddard, J. Chem. Phys. 121, 4068 (2004)
        'GGA_XC_B97_D'                 : 170, # S. Grimme, J. Comput. Chem. 27, 1787 (2006)
        'GGA_XC_B97_GGA1'              : 96 , # A. J. Cohen and N. C. Handy, Chem. Phys. Lett. 316, 160 (2000)
        'GGA_XC_BEEFVDW'               : 286, # J. Wellendorff, K. T. Lundgaard, A. Mogelhoj, V. Petzold, D. D. Landis, J. K. Norskov, T. Bligaard, and K. W. Jacobsen, Phys. Rev. B 85, 235149 (2012)
        'GGA_XC_EDF1'                  : 165, # R. D. Adamson, P. M. W. Gill, and J. A. Pople, Chem. Phys. Lett. 284, 6 (1998)
        'GGA_XC_HCTH_120'              : 162, # A. D. Boese, N. L. Doltsinis, N. C. Handy, and M. Sprik, J. Chem. Phys. 112, 1670 (2000)
        'GGA_XC_HCTH_147'              : 163, # A. D. Boese, N. L. Doltsinis, N. C. Handy, and M. Sprik, J. Chem. Phys. 112, 1670 (2000)
        'GGA_XC_HCTH_407'              : 164, # A. D. Boese and N. C. Handy, J. Chem. Phys. 114, 5497 (2001)
        'GGA_XC_HCTH_407P'             : 93 , # A. D. Boese, A. Chandra, J. M. L. Martin, and D. Marx, J. Chem. Phys. 119, 5965 (2003)
        'GGA_XC_HCTH_93'               : 161, # F. A. Hamprecht, A. J. Cohen, D. J. Tozer, and N. C. Handy, J. Chem. Phys. 109, 6264 (1998)
        'GGA_XC_HCTH_P14'              : 95 , # G. Menconi, P. J. Wilson, and D. J. Tozer, J. Chem. Phys. 114, 3958 (2001)
        'GGA_XC_HCTH_P76'              : 94 , # G. Menconi, P. J. Wilson, and D. J. Tozer, J. Chem. Phys. 114, 3958 (2001)
        'GGA_XC_HLE16'                 : 545, # P. Verma and D. G. Truhlar, J. Phys. Chem. Lett. 8, 380 (2017)
        'GGA_XC_KT1'                   : 167, # T. W. Keal and D. J. Tozer, J. Chem. Phys. 119, 3015 (2003)
        'GGA_XC_KT2'                   : 146, # T. W. Keal and D. J. Tozer, J. Chem. Phys. 119, 3015 (2003)
        'GGA_XC_KT3'                   : 587, # T. W. Keal and D. J. Tozer, J. Chem. Phys. 121, 5654 (2004)
        'GGA_XC_LB07'                  : 589, # E. Livshits and R. Baer, Phys. Chem. Chem. Phys. 9, 2932 (2007)
        'GGA_XC_MOHLYP'                : 194, # N. E. Schultz, Y. Zhao, and D. G. Truhlar, J. Phys. Chem. A 109, 11127 (2005)
        'GGA_XC_MOHLYP2'               : 195, # J. Zheng, Y. Zhao, and D. G. Truhlar, J. Chem. Theory Comput. 5, 808 (2009)
        'GGA_XC_MPWLYP1W'              : 174, # E. E. Dahlke and D. G. Truhlar, J. Phys. Chem. B 109, 15677 (2005)
        'GGA_XC_NCAP'                  : 181, # J. Carmona-Espindola, J. L. Gazquez, A. Vela, and S. B. Trickey, J. Chem. Theory Comput. 15, 303 (2019)
        'GGA_XC_OBLYP_D'               : 67 , # L. Goerigk and S. Grimme, J. Chem. Theory Comput. 6, 107 (2010)
        'GGA_XC_OPBE_D'                : 65 , # L. Goerigk and S. Grimme, J. Chem. Theory Comput. 6, 107 (2010)
        'GGA_XC_OPWLYP_D'              : 66 , # L. Goerigk and S. Grimme, J. Chem. Theory Comput. 6, 107 (2010)
        'GGA_XC_PBE1W'                 : 173, # E. E. Dahlke and D. G. Truhlar, J. Phys. Chem. B 109, 15677 (2005)
        'GGA_XC_PBELYP1W'              : 175, # E. E. Dahlke and D. G. Truhlar, J. Phys. Chem. B 109, 15677 (2005)
        'GGA_XC_TH1'                   : 154, # D. J. Tozer and N. C. Handy, J. Chem. Phys. 108, 2545 (1998)
        'GGA_XC_TH2'                   : 155, # D. J. Tozer and N. C. Handy, J. Phys. Chem. A 102, 3162 (1998)
        'GGA_XC_TH3'                   : 156, # N. C. Handy and D. J. Tozer, Mol. Phys. 94, 707 (1998)
        'GGA_XC_TH4'                   : 157, # N. C. Handy and D. J. Tozer, Mol. Phys. 94, 707 (1998)
        'GGA_XC_TH_FC'                 : 197, # D. J. Tozer, N. C. Handy, and W. H. Green, Chem. Phys. Lett. 273, 183 (1997)
        'GGA_XC_TH_FCFO'               : 198, # D. J. Tozer, N. C. Handy, and W. H. Green, Chem. Phys. Lett. 273, 183 (1997)
        'GGA_XC_TH_FCO'                : 199, # D. J. Tozer, N. C. Handy, and W. H. Green, Chem. Phys. Lett. 273, 183 (1997)
        'GGA_XC_TH_FL'                 : 196, # D. J. Tozer, N. C. Handy, and W. H. Green, Chem. Phys. Lett. 273, 183 (1997)
        'GGA_XC_VV10'                  : 255, # O. A. Vydrov and T. Van Voorhis, J. Chem. Phys. 133, 244103 (2010)
        'GGA_XC_XLYP'                  : 166, # X. Xu and W. A. Goddard, Proc. Natl. Acad. Sci. U. S. A. 101, 2673 (2004)
        #'HYB_GGA_X_LC2GAU'             : 710, # J.-W. Song, M. A. Watson, and K. Hirao, J. Chem. Phys. 131, 144108 (2009)
        #'HYB_GGA_X_LCGAU'              : 708, # J.-W. Song, S. Tokura, T. Sato, M. A. Watson, and K. Hirao, J. Chem. Phys. 127, 154109 (2007)
        #'HYB_GGA_X_LCGAU_CORE'         : 709, # J.-W. Song, M. A. Watson, A. Nakata, and K. Hirao, J. Chem. Phys. 129, 184113 (2008)
        'HYB_GGA_X_N12_SX'             : 81 , # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 16187 (2012)
        'HYB_GGA_X_S12H'               : 496, # M. Swart, Chem. Phys. Lett. 580, 166 (2013)
        'HYB_GGA_X_SOGGA11_X'          : 426, # R. Peverati and D. G. Truhlar, J. Chem. Phys. 135, 191102 (2011)
        'HYB_GGA_XC_APBE0'             : 607, # E. Fabiano, L. A. Constantin, P. Cortona, and F. Della Sala, J. Chem. Theory Comput. 11, 122 (2015)
        'HYB_GGA_XC_APF'               : 409, # A. Austin, G. A. Petersson, M. J. Frisch, F. J. Dobek, G. Scalmani, and K. Throssell, J. Chem. Theory Comput. 8, 4989 (2012)
        'HYB_GGA_XC_B1LYP'             : 416, # C. Adamo and V. Barone, Chem. Phys. Lett. 274, 242 (1997)
        'HYB_GGA_XC_B1PW91'            : 417, # C. Adamo and V. Barone, Chem. Phys. Lett. 274, 242 (1997)
        'HYB_GGA_XC_B1WC'              : 412, # D. I. Bilc, R. Orlando, R. Shaltaf, G.-M. Rignanese, J. Iniguez, and P. Ghosez, Phys. Rev. B 77, 165107 (2008)
        #'HYB_GGA_XC_B2PLYP'            : 713, # S. Grimme, J. Chem. Phys. 124, 034108 (2006)
        'HYB_GGA_XC_B3LYP'             : 402, # P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch, J. Phys. Chem. 98, 11623 (1994)
        'HYB_GGA_XC_B3LYP5'            : 475, # P. J. Stephens, F. J. Devlin, C. F. Chabalowski, and M. J. Frisch, J. Phys. Chem. 98, 11623 (1994)
        'HYB_GGA_XC_B3LYP_MCM1'        : 461, # M. T. Caldeira and R. Custodio, J. Mol. Model. 25, 62 (2019)
        'HYB_GGA_XC_B3LYP_MCM2'        : 462, # M. T. Caldeira and R. Custodio, J. Mol. Model. 25, 62 (2019)
        'HYB_GGA_XC_B3LYPS'            : 459, # M. Reiher, O. Salomon, and B. A. Hess, Theor. Chem. Acc. 107, 48 (2001)
        'HYB_GGA_XC_B3P86'             : 403, # Defined through Gaussian implementation
        #'HYB_GGA_XC_B3P86_NWCHEM'      : 315, # Defined through NWChem implementation
        'HYB_GGA_XC_B3PW91'            : 401, # A. D. Becke, J. Chem. Phys. 98, 5648 (1993)
        'HYB_GGA_XC_B5050LYP'          : 572, # Y. Shao, M. Head-Gordon, and A. I. Krylov, J. Chem. Phys. 118, 4807 (2003)
        'HYB_GGA_XC_B97'               : 407, # A. D. Becke, J. Chem. Phys. 107, 8554 (1997)
        'HYB_GGA_XC_B97_1'             : 408, # F. A. Hamprecht, A. J. Cohen, D. J. Tozer, and N. C. Handy, J. Chem. Phys. 109, 6264 (1998)
        'HYB_GGA_XC_B97_1P'            : 266, # A. J. Cohen and N. C. Handy, Chem. Phys. Lett. 316, 160 (2000)
        'HYB_GGA_XC_B97_2'             : 410, # P. J. Wilson, T. J. Bradley, and D. J. Tozer, J. Chem. Phys. 115, 9233 (2001)
        'HYB_GGA_XC_B97_3'             : 414, # T. W. Keal and D. J. Tozer, J. Chem. Phys. 123, 121103 (2005)
        'HYB_GGA_XC_B97_K'             : 413, # A. D. Boese and J. M. L. Martin, J. Chem. Phys. 121, 3405 (2004)
        'HYB_GGA_XC_BHANDH'            : 435, # A. D. Becke, J. Chem. Phys. 98, 1372 (1993)
        'HYB_GGA_XC_BHANDHLYP'         : 436, # A. D. Becke, J. Chem. Phys. 98, 1372 (1993)
        'HYB_GGA_XC_BLYP35'            : 499, # M. Renz, K. Theilacker, C. Lambert, and M. Kaupp, J. Am. Chem. Soc. 131, 16292 (2009)
        'HYB_GGA_XC_CAM_B3LYP'         : 433, # T. Yanai, D. P. Tew, and N. C. Handy, Chem. Phys. Lett. 393, 51 (2004)
        'HYB_GGA_XC_CAM_O3LYP'         : 395, # M. P. Bircher and U. Rothlisberger, J. Chem. Theory Comput. 14, 3184 (2018)
        'HYB_GGA_XC_CAM_PBEH'          : 681, # W. Chen, G. Miceli, G.-M. Rignanese, and A. Pasquarello, Phys. Rev. Mater. 2, 073803 (2018)
        'HYB_GGA_XC_CAM_QTP_00'        : 490, # P. Verma and R. J. Bartlett, J. Chem. Phys. 140, 18A534 (2014)
        'HYB_GGA_XC_CAM_QTP_01'        : 482, # Y. Jin and R. J. Bartlett, J. Chem. Phys. 145, 034107 (2016)
        'HYB_GGA_XC_CAM_QTP_02'        : 491, # R. L. A. Haiduke and R. J. Bartlett, J. Chem. Phys. 148, 184106 (2018)
        'HYB_GGA_XC_CAMH_B3LYP'        : 614, # Y. Shao, Y. Mei, D. Sundholm, and V. R. I. Kaila, J. Chem. Theory Comput. 16, 587 (2020), https://doi.org/10.1021/acs.jctc.9b00823
        'HYB_GGA_XC_CAMY_B3LYP'        : 470, # M. Seth and T. Ziegler, J. Chem. Theory Comput. 8, 901 (2012)
        'HYB_GGA_XC_CAMY_BLYP'         : 455, # Y. Akinaga and S. Ten-no, Chem. Phys. Lett. 462, 348 (2008)
        'HYB_GGA_XC_CAMY_PBEH'         : 682, # W. Chen, G. Miceli, G.-M. Rignanese, and A. Pasquarello, Phys. Rev. Mater. 2, 073803 (2018)
        'HYB_GGA_XC_CAP0'              : 477, # J. Carmona-Espindola, J. L. Gazquez, A. Vela, and S. B. Trickey, Theor. Chem. Acc. 135, 120 (2016)
        'HYB_GGA_XC_EDF2'              : 476, # C. Y. Lin, M. W. George, and P. M. W. Gill, Aust. J. Chem. 57, 365 (2004)
        'HYB_GGA_XC_HAPBE'             : 608, # E. Fabiano, L. A. Constantin, P. Cortona, and F. Della Sala, J. Chem. Theory Comput. 11, 122 (2015)
        'HYB_GGA_XC_HFLYP'             : 314, # C. Lee, W. Yang, and R. G. Parr, Phys. Rev. B 37, 785 (1988)
        #'HYB_GGA_XC_HISS'              : 717, # T. M. Henderson, A. F. Izmaylov, G. E. Scuseria, and A. Savin, J. Chem. Phys. 127, 221103 (2007)
        'HYB_GGA_XC_HJS_B88'           : 431, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'HYB_GGA_XC_HJS_B97X'          : 432, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'HYB_GGA_XC_HJS_PBE'           : 429, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'HYB_GGA_XC_HJS_PBE_SOL'       : 430, # T. M. Henderson, B. G. Janesko, and G. E. Scuseria, J. Chem. Phys. 128, 194105 (2008)
        'HYB_GGA_XC_HPBEINT'           : 472, # E. Fabiano, L. A. Constantin, and F. Della Sala, Int. J. Quantum Chem. 113, 673 (2013)
        'HYB_GGA_XC_HSE03'             : 427, # J. Heyd, G. E. Scuseria, and M. Ernzerhof, J. Chem. Phys. 118, 8207 (2003)
        'HYB_GGA_XC_HSE06'             : 428, # J. Heyd, G. E. Scuseria, and M. Ernzerhof, J. Chem. Phys. 118, 8207 (2003)
        'HYB_GGA_XC_HSE12'             : 479, # J. E. Moussa, P. A. Schultz, and J. R. Chelikowsky, J. Chem. Phys. 136, 204117 (2012)
        'HYB_GGA_XC_HSE12S'            : 480, # J. E. Moussa, P. A. Schultz, and J. R. Chelikowsky, J. Chem. Phys. 136, 204117 (2012)
        'HYB_GGA_XC_HSE_SOL'           : 481, # L. Schimka, J. Harl, and G. Kresse, J. Chem. Phys. 134, 024116 (2011)
        'HYB_GGA_XC_KMLYP'             : 485, # J. K. Kang and C. B. Musgrave, J. Chem. Phys. 115, 11040 (2001)
        'HYB_GGA_XC_LC_BLYP'           : 400, # L. N. Anderson, M. B. Oviedo, and B. M. Wong, J. Chem. Theory Comput. 13, 1656 (2017)
        'HYB_GGA_XC_LC_BOP'            : 636, # J.-W. Song, T. Hirosawa, T. Tsuneda, and K. Hirao, J. Chem. Phys. 126, 154105 (2007)
        'HYB_GGA_XC_LC_PBEOP'          : 637, # Y. Tawada, T. Tsuneda, S. Yanagisawa, T. Yanai, and K. Hirao, J. Chem. Phys. 120, 8425 (2004)
        'HYB_GGA_XC_LC_QTP'            : 492, # R. L. A. Haiduke and R. J. Bartlett, J. Chem. Phys. 148, 184106 (2018)
        'HYB_GGA_XC_LC_VV10'           : 469, # O. A. Vydrov and T. Van Voorhis, J. Chem. Phys. 133, 244103 (2010)
        'HYB_GGA_XC_LC_WPBE'           : 478, # O. A. Vydrov and G. E. Scuseria, J. Chem. Phys. 125, 234109 (2006)
        'HYB_GGA_XC_LC_WPBE08_WHS'     : 488, # E. Weintraub, T. M. Henderson, and G. E. Scuseria, J. Chem. Theory Comput. 5, 754 (2009)
        'HYB_GGA_XC_LC_WPBE_WHS'       : 486, # E. Weintraub, T. M. Henderson, and G. E. Scuseria, J. Chem. Theory Comput. 5, 754 (2009)
        'HYB_GGA_XC_LC_WPBEH_WHS'      : 487, # E. Weintraub, T. M. Henderson, and G. E. Scuseria, J. Chem. Theory Comput. 5, 754 (2009)
        'HYB_GGA_XC_LC_WPBESOL_WHS'    : 489, # E. Weintraub, T. M. Henderson, and G. E. Scuseria, J. Chem. Theory Comput. 5, 754 (2009)
        'HYB_GGA_XC_LCY_BLYP'          : 468, # Y. Akinaga and S. Ten-no, Chem. Phys. Lett. 462, 348 (2008)
        'HYB_GGA_XC_LCY_PBE'           : 467, # M. Seth and T. Ziegler, J. Chem. Theory Comput. 8, 901 (2012)
        'HYB_GGA_XC_LRC_WPBE'          : 473, # M. A. Rohrdanz, K. M. Martins, and J. M. Herbert, J. Chem. Phys. 130, 054112 (2009)
        'HYB_GGA_XC_LRC_WPBEH'         : 465, # M. A. Rohrdanz, K. M. Martins, and J. M. Herbert, J. Chem. Phys. 130, 054112 (2009)
        'HYB_GGA_XC_MB3LYP_RC04'       : 437, # V. Tognetti, P. Cortona, and C. Adamo, Chem. Phys. Lett. 439, 381 (2007)
        'HYB_GGA_XC_MPW1K'             : 405, # B. J. Lynch, P. L. Fast, M. Harris, and D. G. Truhlar, J. Phys. Chem. A 104, 4811 (2000)
        'HYB_GGA_XC_MPW1LYP'           : 483, # C. Adamo and V. Barone, J. Chem. Phys. 108, 664 (1998)
        'HYB_GGA_XC_MPW1PBE'           : 484, # C. Adamo and V. Barone, J. Chem. Phys. 108, 664 (1998)
        'HYB_GGA_XC_MPW1PW'            : 418, # C. Adamo and V. Barone, J. Chem. Phys. 108, 664 (1998)
        'HYB_GGA_XC_MPW3LYP'           : 419, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 108, 6908 (2004)
        'HYB_GGA_XC_MPW3PW'            : 415, # C. Adamo and V. Barone, J. Chem. Phys. 108, 664 (1998)
        'HYB_GGA_XC_MPWLYP1M'          : 453, # N. E. Schultz, Y. Zhao, and D. G. Truhlar, J. Phys. Chem. A 109, 11127 (2005)
        'HYB_GGA_XC_O3LYP'             : 404, # A. J. Cohen and N. C. Handy, Mol. Phys. 99, 607 (2001)
        'HYB_GGA_XC_PBE0_13'           : 456, # P. Cortona, J. Chem. Phys. 136, 086101 (2012)
        'HYB_GGA_XC_PBE50'             : 290, # Y. A. Bernard, Y. Shao, and A. I. Krylov, J. Chem. Phys. 136, 204103 (2012)
        'HYB_GGA_XC_PBE_MOL0'          : 273, # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'HYB_GGA_XC_PBE_MOLB0'         : 276, # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'HYB_GGA_XC_PBE_SOL0'          : 274, # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'HYB_GGA_XC_PBEB0'             : 275, # J. M. del Campo, J. L. Gazquez, S. B. Trickey, and A. Vela, J. Chem. Phys. 136, 104108 (2012)
        'HYB_GGA_XC_PBEH'              : 406, # C. Adamo and V. Barone, J. Chem. Phys. 110, 6158 (1999)
        'HYB_GGA_XC_QTP17'             : 460, # Y. Jin and R. J. Bartlett, J. Chem. Phys. 149, 064111 (2018)
        'HYB_GGA_XC_RCAM_B3LYP'        : 610, # A. J. Cohen, P. Mori-Sanchez, and W. Yang, J. Chem. Phys. 126, 191109 (2007)
        'HYB_GGA_XC_REVB3LYP'          : 454, # L. Lu, H. Hu, H. Hou, and B. Wang, Comput. Theor. Chem. 1015, 64 (2013)
        'HYB_GGA_XC_SB98_1A'           : 420, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        'HYB_GGA_XC_SB98_1B'           : 421, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        'HYB_GGA_XC_SB98_1C'           : 422, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        'HYB_GGA_XC_SB98_2A'           : 423, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        'HYB_GGA_XC_SB98_2B'           : 424, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        'HYB_GGA_XC_SB98_2C'           : 425, # H. L. Schmider and A. D. Becke, J. Chem. Phys. 108, 9624 (1998)
        #'HYB_GGA_XC_SRC1_BLYP'         : 714, # N. A. Besley, M. J. G. Peach, and D. J. Tozer, Phys. Chem. Chem. Phys. 11, 10350 (2009)
        #'HYB_GGA_XC_SRC2_BLYP'         : 715, # N. A. Besley, M. J. G. Peach, and D. J. Tozer, Phys. Chem. Chem. Phys. 11, 10350 (2009)
        'HYB_GGA_XC_TUNED_CAM_B3LYP'   : 434, # K. Okuno, Y. Shigeta, R. Kishi, H. Miyasaka, and M. Nakano, J. Photochem. Photobiol., A 235, 29 (2012)
        'HYB_GGA_XC_WB97'              : 463, # J.-D. Chai and M. Head-Gordon, J. Chem. Phys. 128, 084106 (2008)
        'HYB_GGA_XC_WB97X'             : 464, # J.-D. Chai and M. Head-Gordon, J. Chem. Phys. 128, 084106 (2008)
        'HYB_GGA_XC_WB97X_D'           : 471, # J.-D. Chai and M. Head-Gordon, Phys. Chem. Chem. Phys. 10, 6615 (2008)
        'HYB_GGA_XC_WB97X_D3'          : 399, # Y.-S. Lin, G.-D. Li, S.-P. Mao, and J.-D. Chai, J. Chem. Theory Comput. 9, 263 (2013)
        'HYB_GGA_XC_WB97X_V'           : 466, # N. Mardirossian and M. Head-Gordon, Phys. Chem. Chem. Phys. 16, 9904 (2014)
        'HYB_GGA_XC_WC04'              : 611, # K. W. Wiitala, T. R. Hoye, and C. J. Cramer, J. Chem. Theory Comput. 2, 1085 (2006)
        'HYB_GGA_XC_WHPBE0'            : 615, # Y. Shao, Y. Mei, D. Sundholm, and V. R. I. Kaila, J. Chem. Theory Comput. 16, 587 (2020), https://doi.org/10.1021/acs.jctc.9b00823
        'HYB_GGA_XC_WP04'              : 612, # K. W. Wiitala, T. R. Hoye, and C. J. Cramer, J. Chem. Theory Comput. 2, 1085 (2006)
        'HYB_GGA_XC_X3LYP'             : 411, # X. Xu and W. A. Goddard, Proc. Natl. Acad. Sci. U. S. A. 101, 2673 (2004)
        'MGGA_C_B88'                   : 571, # A. D. Becke, J. Chem. Phys. 88, 1053 (1988)
        'MGGA_C_B94'                   : 397, # A. D. Becke, Int. J. Quantum Chem. 52, 625 (1994)
        'MGGA_C_BC95'                  : 240, # A. D. Becke, J. Chem. Phys. 104, 1040 (1996)
        'MGGA_C_CS'                    : 72 , # R. Colle and O. Salvetti, Theor. Chim. Acta 37, 329 (1975)
        'MGGA_C_DLDF'                  : 37 , # K. Pernal, R. Podeszwa, K. Patkowski, and K. Szalewicz, Phys. Rev. Lett. 103, 263201 (2009)
        'MGGA_C_HLTAPW'                : 699, # S. Lehtola and M. A. L. Marques, Meta-local density functionals: a new rung on jacob's ladder, (2020), arXiv:2006.16835 [physics.chem-ph]
        'MGGA_C_KCIS'                  : 562, # J. Rey and A. Savin, Int. J. Quantum Chem. 69, 581 (1998)
        'MGGA_C_KCISK'                 : 638, # J. Rey and A. Savin, Int. J. Quantum Chem. 69, 581 (1998)
        'MGGA_C_M05'                   : 237, # Y. Zhao, N. E. Schultz, and D. G. Truhlar, J. Chem. Phys. 123, 161103 (2005)
        'MGGA_C_M05_2X'                : 238, # Y. Zhao, N. E. Schultz, and D. G. Truhlar, J. Chem. Theory Comput. 2, 364 (2006)
        'MGGA_C_M06'                   : 235, # Y. Zhao and D. G. Truhlar, Theor. Chem. Acc. 120, 215 (2008)
        'MGGA_C_M06_2X'                : 236, # Y. Zhao and D. G. Truhlar, Theor. Chem. Acc. 120, 215 (2008)
        'MGGA_C_M06_HF'                : 234, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 110, 13126 (2006)
        'MGGA_C_M06_L'                 : 233, # Y. Zhao and D. G. Truhlar, J. Chem. Phys. 125, 194101 (2006)
        'MGGA_C_M06_SX'                : 311, # Y. Wang, P. Verma, L. Zhang, Y. Li, Z. Liu, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 117, 2294 (2020), https://www.pnas.org/content/117/5/2294.full.pdf
        'MGGA_C_M08_HX'                : 78 , # Y. Zhao and D. G. Truhlar, J. Chem. Theory Comput. 4, 1849 (2008)
        'MGGA_C_M08_SO'                : 77 , # Y. Zhao and D. G. Truhlar, J. Chem. Theory Comput. 4, 1849 (2008)
        'MGGA_C_M11'                   : 76 , # R. Peverati and D. G. Truhlar, J. Phys. Chem. Lett. 2, 2810 (2011)
        'MGGA_C_M11_L'                 : 75 , # R. Peverati and D. G. Truhlar, J. Phys. Chem. Lett. 3, 117 (2012)
        'MGGA_C_MN12_L'                : 74 , # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 13171 (2012)
        'MGGA_C_MN12_SX'               : 73 , # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 16187 (2012)
        'MGGA_C_MN15'                  : 269, # H. S. Yu, X. He, S. L. Li, and D. G. Truhlar, Chem. Sci. 7, 5032 (2016)
        'MGGA_C_MN15_L'                : 261, # H. S. Yu, X. He, and D. G. Truhlar, J. Chem. Theory Comput. 12, 1280 (2016)
        'MGGA_C_PKZB'                  : 239, # J. P. Perdew, S. Kurth, A. Zupan, and P. Blaha, Phys. Rev. Lett. 82, 2544 (1999)
        'MGGA_C_R2SCAN'                : 498, # J. W. Furness, A. D. Kaplan, J. Ning, J. P. Perdew, and J. Sun, J. Phys. Chem. Lett. 11, 8208 (2020)
        'MGGA_C_R2SCANL'               : 719, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. B 102, 121109 (2020)
        'MGGA_C_REVM06'                : 306, # Y. Wang, P. Verma, X. Jin, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 115, 10257 (2018)
        'MGGA_C_REVM06_L'              : 294, # Y. Wang, X. Jin, H. S. Yu, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 114, 8487 (2017)
        'MGGA_C_REVM11'                : 172, # P. Verma, Y. Wang, S. Ghosh, X. He, and D. G. Truhlar, J. Phys. Chem. A 123, 2966 (2019)
        'MGGA_C_REVSCAN'               : 582, # P. D. Mezei, G. I. Csonka, and M. Kallay, J. Chem. Theory Comput. 14, 2469 (2018)
        'MGGA_C_REVSCAN_VV10'          : 585, # P. D. Mezei, G. I. Csonka, and M. Kallay, J. Chem. Theory Comput. 14, 2469 (2018)
        'MGGA_C_REVTM'                 : 694, # S. Jana, K. Sharma, and P. Samal, J. Phys. Chem. A 123, 6356 (2019)
        'MGGA_C_REVTPSS'               : 241, # J. P. Perdew, A. Ruzsinszky, G. I. Csonka, L. A. Constantin, and J. Sun, Phys. Rev. Lett. 103, 026403 (2009)
        'MGGA_C_RSCAN'                 : 494, # A. P. Bartok and J. R. Yates, J. Chem. Phys. 150, 161101 (2019)
        'MGGA_C_SCAN'                  : 267, # J. Sun, A. Ruzsinszky, and J. P. Perdew, Phys. Rev. Lett. 115, 036402 (2015)
        'MGGA_C_SCAN_RVV10'            : 292, # H. Peng, Z.-H. Yang, J. P. Perdew, and J. Sun, Phys. Rev. X 6, 041005 (2016)
        'MGGA_C_SCAN_VV10'             : 584, # J. G. Brandenburg, J. E. Bates, J. Sun, and J. P. Perdew, Phys. Rev. B 94, 115144 (2016)
        'MGGA_C_SCANL'                 : 702, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_C_SCANL_RVV10'           : 703, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_C_SCANL_VV10'            : 704, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_C_TM'                    : 251, # J. Tao and Y. Mo, Phys. Rev. Lett. 117, 073001 (2016)
        'MGGA_C_TPSS'                  : 231, # J. Tao, J. P. Perdew, V. N. Staroverov, and G. E. Scuseria, Phys. Rev. Lett. 91, 146401 (2003)
        'MGGA_C_TPSSLOC'               : 247, # L. A. Constantin, E. Fabiano, and F. Della Sala, Phys. Rev. B 86, 035130 (2012)
        'MGGA_C_VSXC'                  : 232, # T. V. Voorhis and G. E. Scuseria, J. Chem. Phys. 109, 400 (1998)
        'MGGA_K_CSK1'                  : 629, # A. C. Cancio, D. Stewart, and A. Kuna, J. Chem. Phys. 144, 084107 (2016)
        'MGGA_K_CSK4'                  : 630, # A. C. Cancio, D. Stewart, and A. Kuna, J. Chem. Phys. 144, 084107 (2016)
        'MGGA_K_CSK_LOC1'              : 631, # A. C. Cancio, D. Stewart, and A. Kuna, J. Chem. Phys. 144, 084107 (2016)
        'MGGA_K_CSK_LOC4'              : 632, # A. C. Cancio, D. Stewart, and A. Kuna, J. Chem. Phys. 144, 084107 (2016)
        'MGGA_K_GEA2'                  : 627, # A. S. Kompaneets and E. S. Pavlovskii, Zh. Eksp. Teor. Fiz. 31, 427 (1956), [J. Exp. Theor. Phys. 4, 328 (1957)]
        'MGGA_K_GEA4'                  : 628, # C. H. Hodges, Can. J. Phys. 51, 1428 (1973)
        'MGGA_K_L04'                   : 617, # S. Laricchia, L. A. Constantin, E. Fabiano, and F. Della Sala, J. Chem. Theory Comput. 10, 164 (2014)
        'MGGA_K_L06'                   : 618, # S. Laricchia, L. A. Constantin, E. Fabiano, and F. Della Sala, J. Chem. Theory Comput. 10, 164 (2014)
        'MGGA_K_PC07'                  : 543, # J. P. Perdew and L. A. Constantin, Phys. Rev. B 75, 155109 (2007)
        'MGGA_K_PC07_OPT'              : 634, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_K_PGSL025'               : 220, # L. A. Constantin, E. Fabiano, and F. Della Sala, J. Phys. Chem. Lett. 9, 4385 (2018), pMID: 30019904
        'MGGA_K_RDA'                   : 621, # V. V. Karasiev, R. S. Jones, S. B. Trickey, and F. E. Harris, Phys. Rev. B 80, 245120 (2009)
        'MGGA_X_2D_JS17'               : 609, # S. Jana and P. Samal, J. Phys. Chem. A 121, 4804 (2017)
        'MGGA_X_2D_PRHG07'             : 210, # S. Pittalis, E. Rasanen, N. Helbig, and E. K. U. Gross, Phys. Rev. B 76, 235314 (2007)
        'MGGA_X_2D_PRHG07_PRP10'       : 211, # S. Pittalis, E. Rasanen, N. Helbig, and E. K. U. Gross, Phys. Rev. B 76, 235314 (2007)
        'MGGA_X_B00'                   : 284, # A. D. Becke, J. Chem. Phys. 112, 4020 (2000)
        'MGGA_X_BJ06'                  : 207, # A. D. Becke and E. R. Johnson, J. Chem. Phys. 124, 221101 (2006)
        'MGGA_X_BLOC'                  : 244, # L. A. Constantin, E. Fabiano, and F. Della Sala, J. Chem. Theory Comput. 9, 2256 (2013)
        'MGGA_X_BR89'                  : 206, # A. D. Becke and M. R. Roussel, Phys. Rev. A 39, 3761 (1989)
        'MGGA_X_BR89_1'                : 214, # A. D. Becke and M. R. Roussel, Phys. Rev. A 39, 3761 (1989)
        'MGGA_X_BR89_EXPLICIT'         : 586, # A. D. Becke and M. R. Roussel, Phys. Rev. A 39, 3761 (1989)
        'MGGA_X_BR89_EXPLICIT_1'       : 602, # A. D. Becke and M. R. Roussel, Phys. Rev. A 39, 3761 (1989)
        'MGGA_X_EDMGGA'                : 686, # J. Tao, J. Chem. Phys. 115, 3519 (2001)
        'MGGA_X_GDME_0'                : 689, # R. M. Koehl, G. K. Odom, and G. E. Scuseria, Mol. Phys. 87, 835 (1996)
        'MGGA_X_GDME_KOS'              : 690, # R. M. Koehl, G. K. Odom, and G. E. Scuseria, Mol. Phys. 87, 835 (1996)
        'MGGA_X_GDME_NV'               : 687, # J. W. Negele and D. Vautherin, Phys. Rev. C 5, 1472 (1972)
        'MGGA_X_GDME_VT'               : 691, # R. M. Koehl, G. K. Odom, and G. E. Scuseria, Mol. Phys. 87, 835 (1996)
        'MGGA_X_GVT4'                  : 204, # T. V. Voorhis and G. E. Scuseria, J. Chem. Phys. 109, 400 (1998)
        'MGGA_X_GX'                    : 575, # P.-F. Loos, J. Chem. Phys. 146, 114108 (2017)
        'MGGA_X_HLTA'                  : 698, # S. Lehtola and M. A. L. Marques, Meta-local density functionals: a new rung on jacob's ladder, (2020), arXiv:2006.16835 [physics.chem-ph]
        'MGGA_X_JK'                    : 256, # P. Jemmer and P. J. Knowles, Phys. Rev. A 51, 3571 (1995)
        'MGGA_X_LTA'                   : 201, # M. Ernzerhof and G. E. Scuseria, J. Chem. Phys. 111, 911 (1999)
        'MGGA_X_M06_L'                 : 203, # Y. Zhao and D. G. Truhlar, J. Chem. Phys. 125, 194101 (2006)
        'MGGA_X_M11_L'                 : 226, # R. Peverati and D. G. Truhlar, J. Phys. Chem. Lett. 3, 117 (2012)
        'MGGA_X_MBEEF'                 : 249, # J. Wellendorff, K. T. Lundgaard, K. W. Jacobsen, and T. Bligaard, J. Chem. Phys. 140, 144107 (2014)
        'MGGA_X_MBEEFVDW'              : 250, # K. T. Lundgaard, J. Wellendorff, J. Voss, K. W. Jacobsen, and T. Bligaard, Phys. Rev. B 93, 235162 (2016)
        'MGGA_X_MBR'                   : 716, # A. Patra, S. Jana, H. Myneni, and P. Samal, Phys. Chem. Chem. Phys. 21, 19639 (2019)
        'MGGA_X_MBRXC_BG'              : 696, # B. Patra, S. Jana, L. A. Constantin, and P. Samal, Phys. Rev. B 100, 045147 (2019)
        'MGGA_X_MBRXH_BG'              : 697, # B. Patra, S. Jana, L. A. Constantin, and P. Samal, Phys. Rev. B 100, 045147 (2019)
        'MGGA_X_MGGAC'                 : 711, # B. Patra, S. Jana, L. A. Constantin, and P. Samal, Phys. Rev. B 100, 155140 (2019)
        'MGGA_X_MK00'                  : 230, # F. R. Manby and P. J. Knowles, J. Chem. Phys. 112, 7002 (2000)
        'MGGA_X_MK00B'                 : 243, # F. R. Manby and P. J. Knowles, J. Chem. Phys. 112, 7002 (2000)
        'MGGA_X_MN12_L'                : 227, # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 13171 (2012)
        'MGGA_X_MN15_L'                : 260, # H. S. Yu, X. He, and D. G. Truhlar, J. Chem. Theory Comput. 12, 1280 (2016)
        'MGGA_X_MODTPSS'               : 245, # J. P. Perdew, A. Ruzsinszky, J. Tao, G. I. Csonka, and G. E. Scuseria, Phys. Rev. A 76, 042506 (2007)
        'MGGA_X_MS0'                   : 221, # J. Sun, B. Xiao, and A. Ruzsinszky, J. Chem. Phys. 137, 051101 (2012)
        'MGGA_X_MS1'                   : 222, # J. Sun, R. Haunschild, B. Xiao, I. W. Bulik, G. E. Scuseria, and J. P. Perdew, J. Chem. Phys. 138, 044113 (2013)
        'MGGA_X_MS2'                   : 223, # J. Sun, R. Haunschild, B. Xiao, I. W. Bulik, G. E. Scuseria, and J. P. Perdew, J. Chem. Phys. 138, 044113 (2013)
        'MGGA_X_MS2_REV'               : 228, # J. Sun, R. Haunschild, B. Xiao, I. W. Bulik, G. E. Scuseria, and J. P. Perdew, J. Chem. Phys. 138, 044113 (2013)
        'MGGA_X_MS2B'                  : 300, # J. W. Furness and J. Sun, Phys. Rev. B 99, 041119 (2019)
        'MGGA_X_MS2BS'                 : 301, # J. W. Furness and J. Sun, ArXiv e-prints (2018), arXiv:1805.11707v1 [physics.chem-ph]
        'MGGA_X_MVS'                   : 257, # J. Sun, J. P. Perdew, and A. Ruzsinszky, Proc. Natl. Acad. Sci. U. S. A. 112, 685 (2015)
        'MGGA_X_MVSB'                  : 302, # J. W. Furness and J. Sun, ArXiv e-prints (2018), arXiv:1805.11707v1 [physics.chem-ph]
        'MGGA_X_MVSBS'                 : 303, # J. W. Furness and J. Sun, ArXiv e-prints (2018), arXiv:1805.11707v1 [physics.chem-ph]
        'MGGA_X_PBE_GX'                : 576, # P.-F. Loos, J. Chem. Phys. 146, 114108 (2017)
        'MGGA_X_PKZB'                  : 213, # J. P. Perdew, S. Kurth, A. Zupan, and P. Blaha, Phys. Rev. Lett. 82, 2544 (1999)
        'MGGA_X_R2SCAN'                : 497, # J. W. Furness, A. D. Kaplan, J. Ning, J. P. Perdew, and J. Sun, J. Phys. Chem. Lett. 11, 8208 (2020)
        'MGGA_X_R2SCANL'               : 718, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. B 102, 121109 (2020)
        'MGGA_X_REGTPSS'               : 603, # A. Ruzsinszky, J. Sun, B. Xiao, and G. I. Csonka, J. Chem. Theory Comput. 8, 2078 (2012)
        'MGGA_X_REVM06_L'              : 293, # Y. Wang, X. Jin, H. S. Yu, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 114, 8487 (2017)
        'MGGA_X_REVSCAN'               : 581, # P. D. Mezei, G. I. Csonka, and M. Kallay, J. Chem. Theory Comput. 14, 2469 (2018)
        'MGGA_X_REVSCANL'              : 701, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_X_REVTM'                 : 693, # S. Jana, K. Sharma, and P. Samal, J. Phys. Chem. A 123, 6356 (2019)
        'MGGA_X_REVTPSS'               : 212, # J. P. Perdew, A. Ruzsinszky, G. I. Csonka, L. A. Constantin, and J. Sun, Phys. Rev. Lett. 103, 026403 (2009)
        'MGGA_X_RLDA'                  : 688, # X. Campi and A. Bouyssy, Phys. Lett. B 73, 263 (1978)
        'MGGA_X_RPP09'                 : 209, # E. Rasanen, S. Pittalis, and C. R. Proetto, J. Chem. Phys. 132, 044112 (2010)
        'MGGA_X_RSCAN'                 : 493, # A. P. Bartok and J. R. Yates, J. Chem. Phys. 150, 161101 (2019)
        'MGGA_X_RTPSS'                 : 299, # A. J. Garza, A. T. Bell, and M. Head-Gordon, J. Chem. Theory Comput. 14, 3083 (2018)
        'MGGA_X_SA_TPSS'               : 542, # L. A. Constantin, E. Fabiano, J. M. Pitarke, and F. Della Sala, Phys. Rev. B 93, 115127 (2016)
        'MGGA_X_SCAN'                  : 263, # J. Sun, A. Ruzsinszky, and J. P. Perdew, Phys. Rev. Lett. 115, 036402 (2015)
        'MGGA_X_SCANL'                 : 700, # D. Mejia-Rodriguez and S. B. Trickey, Phys. Rev. A 96, 052512 (2017)
        'MGGA_X_TASK'                  : 707, # T. Aschebrock and S. Kummel, Phys. Rev. Res. 1, 033082 (2019)
        'MGGA_X_TAU_HCTH'              : 205, # A. D. Boese and N. C. Handy, J. Chem. Phys. 116, 9559 (2002)
        'MGGA_X_TB09'                  : 208, # F. Tran and P. Blaha, Phys. Rev. Lett. 102, 226401 (2009)
        'MGGA_X_TH'                    : 225, # T. Tsuneda and K. Hirao, Phys. Rev. B 62, 15527 (2000)
        'MGGA_X_TLDA'                  : 685, # F. G. Eich and M. Hellgren, J. Chem. Phys. 141, 224107 (2014)
        'MGGA_X_TM'                    : 540, # J. Tao and Y. Mo, Phys. Rev. Lett. 117, 073001 (2016)
        'MGGA_X_TPSS'                  : 202, # J. Tao, J. P. Perdew, V. N. Staroverov, and G. E. Scuseria, Phys. Rev. Lett. 91, 146401 (2003)
        'MGGA_X_VT84'                  : 541, # J. M. del Campo, J. L. Gazquez, S. Trickey, and A. Vela, Chem. Phys. Lett. 543, 179 (2012)
        'MGGA_XC_B97M_V'               : 254, # N. Mardirossian and M. Head-Gordon, J. Chem. Phys. 142, 074111 (2015)
        'MGGA_XC_CC06'                 : 229, # A. C. Cancio and M. Y. Chou, Phys. Rev. B 74, 081202 (2006)
        'MGGA_XC_HLE17'                : 288, # P. Verma and D. G. Truhlar, J. Phys. Chem. C 121, 7144 (2017)
        'MGGA_XC_LP90'                 : 564, # C. Lee and R. G. Parr, Phys. Rev. A 42, 193 (1990)
        'MGGA_XC_OTPSS_D'              : 64 , # L. Goerigk and S. Grimme, J. Chem. Theory Comput. 6, 107 (2010)
        'MGGA_XC_TPSSLYP1W'            : 242, # E. E. Dahlke and D. G. Truhlar, J. Phys. Chem. B 109, 15677 (2005)
        'MGGA_XC_ZLP'                  : 42 , # Q. Zhao, M. Levy, and R. G. Parr, Phys. Rev. A 47, 918 (1993)
        'HYB_MGGA_X_BMK'               : 279, # A. D. Boese and J. M. L. Martin, J. Chem. Phys. 121, 3405 (2004)
        'HYB_MGGA_X_DLDF'              : 36 , # K. Pernal, R. Podeszwa, K. Patkowski, and K. Szalewicz, Phys. Rev. Lett. 103, 263201 (2009)
        'HYB_MGGA_X_JS18'              : 705, # S. Jana and P. Samal, Phys. Chem. Chem. Phys. 20, 8999 (2018)
        'HYB_MGGA_X_M05'               : 438, # Y. Zhao, N. E. Schultz, and D. G. Truhlar, J. Chem. Phys. 123, 161103 (2005)
        'HYB_MGGA_X_M05_2X'            : 439, # Y. Zhao, N. E. Schultz, and D. G. Truhlar, J. Chem. Theory Comput. 2, 364 (2006)
        'HYB_MGGA_X_M06'               : 449, # Y. Zhao and D. G. Truhlar, Theor. Chem. Acc. 120, 215 (2008)
        'HYB_MGGA_X_M06_2X'            : 450, # Y. Zhao and D. G. Truhlar, Theor. Chem. Acc. 120, 215 (2008)
        'HYB_MGGA_X_M06_HF'            : 444, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 110, 13126 (2006)
        'HYB_MGGA_X_M06_SX'            : 310, # Y. Wang, P. Verma, L. Zhang, Y. Li, Z. Liu, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 117, 2294 (2020), https://www.pnas.org/content/117/5/2294.full.pdf
        'HYB_MGGA_X_M08_HX'            : 295, # Y. Zhao and D. G. Truhlar, J. Chem. Theory Comput. 4, 1849 (2008)
        'HYB_MGGA_X_M08_SO'            : 296, # Y. Zhao and D. G. Truhlar, J. Chem. Theory Comput. 4, 1849 (2008)
        'HYB_MGGA_X_M11'               : 297, # R. Peverati and D. G. Truhlar, J. Phys. Chem. Lett. 2, 2810 (2011)
        'HYB_MGGA_X_MN12_SX'           : 248, # R. Peverati and D. G. Truhlar, Phys. Chem. Chem. Phys. 14, 16187 (2012)
        'HYB_MGGA_X_MN15'              : 268, # H. S. Yu, X. He, S. L. Li, and D. G. Truhlar, Chem. Sci. 7, 5032 (2016)
        'HYB_MGGA_X_MS2H'              : 224, # J. Sun, R. Haunschild, B. Xiao, I. W. Bulik, G. E. Scuseria, and J. P. Perdew, J. Chem. Phys. 138, 044113 (2013)
        'HYB_MGGA_X_MVSH'              : 474, # J. Sun, J. P. Perdew, and A. Ruzsinszky, Proc. Natl. Acad. Sci. U. S. A. 112, 685 (2015)
        'HYB_MGGA_X_PJS18'             : 706, # B. Patra, S. Jana, and P. Samal, Phys. Chem. Chem. Phys. 20, 8991 (2018)
        'HYB_MGGA_X_REVM06'            : 305, # Y. Wang, P. Verma, X. Jin, D. G. Truhlar, and X. He, Proc. Natl. Acad. Sci. U. S. A. 115, 10257 (2018)
        'HYB_MGGA_X_REVM11'            : 304, # P. Verma, Y. Wang, S. Ghosh, X. He, and D. G. Truhlar, J. Phys. Chem. A 123, 2966 (2019)
        'HYB_MGGA_X_REVSCAN0'          : 583, # P. D. Mezei, G. I. Csonka, and M. Kallay, J. Chem. Theory Comput. 14, 2469 (2018)
        'HYB_MGGA_X_SCAN0'             : 264, # K. Hui and J.-D. Chai, J. Chem. Phys. 144, 044114 (2016)
        'HYB_MGGA_X_TAU_HCTH'          : 282, # A. D. Boese and N. C. Handy, J. Chem. Phys. 116, 9559 (2002)
        'HYB_MGGA_XC_B0KCIS'           : 563, # J. Toulouse, A. Savin, and C. Adamo, J. Chem. Phys. 117, 10465 (2002)
        'HYB_MGGA_XC_B86B95'           : 441, # A. D. Becke, J. Chem. Phys. 104, 1040 (1996)
        'HYB_MGGA_XC_B88B95'           : 440, # A. D. Becke, J. Chem. Phys. 104, 1040 (1996)
        'HYB_MGGA_XC_B94_HYB'          : 398, # A. D. Becke, Int. J. Quantum Chem. 52, 625 (1994)
        'HYB_MGGA_XC_B98'              : 598, # A. D. Becke, J. Chem. Phys. 109, 2092 (1998)
        'HYB_MGGA_XC_BB1K'             : 443, # Y. Zhao, B. J. Lynch, and D. G. Truhlar, J. Phys. Chem. A 108, 2715 (2004)
        'HYB_MGGA_XC_EDMGGAH'          : 695, # J. Tao, J. Chem. Phys. 116, 2335 (2002)
        'HYB_MGGA_XC_MPW1B95'          : 445, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 108, 6908 (2004)
        'HYB_MGGA_XC_MPW1KCIS'         : 566, # Y. Zhao, N. Gonzalez-Garcia, and D. G. Truhlar, J. Phys. Chem. A 109, 2012 (2005)
        'HYB_MGGA_XC_MPWB1K'           : 446, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 108, 6908 (2004)
        'HYB_MGGA_XC_MPWKCIS1K'        : 567, # Y. Zhao, N. Gonzalez-Garcia, and D. G. Truhlar, J. Phys. Chem. A 109, 2012 (2005)
        'HYB_MGGA_XC_PBE1KCIS'         : 568, # Y. Zhao and D. G. Truhlar, J. Chem. Theory Comput. 1, 415 (2005)
        'HYB_MGGA_XC_PW6B95'           : 451, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 109, 5656 (2005)
        'HYB_MGGA_XC_PW86B95'          : 442, # A. D. Becke, J. Chem. Phys. 104, 1040 (1996)
        'HYB_MGGA_XC_PWB6K'            : 452, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 109, 5656 (2005)
        'HYB_MGGA_XC_REVTPSSH'         : 458, # G. I. Csonka, J. P. Perdew, and A. Ruzsinszky, J. Chem. Theory Comput. 6, 3688 (2010)
        'HYB_MGGA_XC_TPSS0'            : 396, # S. Grimme, J. Phys. Chem. A 109, 3067 (2005)
        'HYB_MGGA_XC_TPSS1KCIS'        : 569, # Y. Zhao, B. J. Lynch, and D. G. Truhlar, Phys. Chem. Chem. Phys. 7, 43 (2005)
        'HYB_MGGA_XC_TPSSH'            : 457, # V. N. Staroverov, G. E. Scuseria, J. Tao, and J. P. Perdew, J. Chem. Phys. 119, 12129 (2003)
        'HYB_MGGA_XC_WB97M_V'          : 531, # N. Mardirossian and M. Head-Gordon, J. Chem. Phys. 144, 214110 (2016)
        'HYB_MGGA_XC_X1B95'            : 447, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 108, 6908 (2004)
        'HYB_MGGA_XC_XB1K'             : 448, # Y. Zhao and D. G. Truhlar, J. Phys. Chem. A 108, 6908 (2004)
    }

    #PROBLEMATIC_XC = dict([(XC_CODES[x], x) for x in
    #                       ('GGA_C_SPBE', 'MGGA_X_REVTPSS')])
    PROBLEMATIC_XC = dict([])

def _xc_key_without_underscore(xc_keys):
    new_xc = []
    for key, xc_id in xc_keys.items():
        for delimeter in ('_XC_', '_X_', '_C_', '_K_'):
            if delimeter in key:
                key0, key1 = key.split(delimeter)
                new_key1 = key1.replace('_', '').replace('-', '')
                if key1 != new_key1:
                    new_xc.append((key0+delimeter+new_key1, xc_id))
                break
    return new_xc
XC_CODES.update(_xc_key_without_underscore(XC_CODES))
del(_xc_key_without_underscore)

#
# alias
#
XC_CODES.update({
    'GGA_C_BCGP'    : 'GGA_C_ACGGA',
    'LDA'           : 1 ,
    'SLATER'        : 1 ,
    'VWN3'          : 8,
    'VWNRPA'        : 8,
    'VWN5'          : 7,
    'B88'           : 106,
    'PBE0'          : 406,
    'PBE1PBE'       : 406,
    'OPTXCORR'      : '0.7344536875999693*SLATER - 0.6984752285760186*OPTX,',
    'B3LYP'         : 'B3LYP5',  # VWN5 version
    'B3LYP5'        : '.2*HF + .08*SLATER + .72*B88, .81*LYP + .19*VWN',
    'B3LYPG'        : 402,  # VWN3, used by Gaussian
    'B3P86'         : 'B3P865',  # VWN5 version
    'B3P865'        : '.2*HF + .08*SLATER + .72*B88, .81*P86 + .19*VWN',
    # FIXME: Check if Gaussian takes a different form for B3P86
    #'B3P86G'        : 403,  # VWN3, used by Gaussian
    'B3P86G'        : '.2*HF + .08*SLATER + .72*B88, .81*P86 + .19*VWN3',
    'B3PW91'        : 'B3PW915',
    'B3PW915'       : '.2*HF + .08*SLATER + .72*B88, .81*PW91 + .19*VWN',
    #'B3PW91G'       : '.2*HF + .08*SLATER + .72*B88, .81*PW91 + .19*VWN3',
    'B3PW91G'       : 401,
    #'O3LYP5'        : '.1161*HF + .9262*SLATER + .8133*OPTXCORR, .81*LYP + .19*VWN5',
    #'O3LYPG'        : '.1161*HF + .9262*SLATER + .8133*OPTXCORR, .81*LYP + .19*VWN3',
    'O3LYP'         : 404, # in libxc == '.1161*HF + 0.071006917*SLATER + .8133*OPTX, .81*LYP + .19*VWN5', may be erroreous
    'MPW3PW'        : 'MPW3PW5',  # VWN5 version
    'MPW3PW5'       : '.2*HF + .08*SLATER + .72*MPW91, .81*PW91 + .19*VWN',
    'MPW3PWG'       : 415,  # VWN3, used by Gaussian
    'MPW3LYP'       : 'MPW3LYP5',  # VWN5 version
    'MPW3LYP5'      : '.218*HF + .073*SLATER + .709*MPW91, .871*LYP + .129*VWN',
    'MPW3LYPG'      : 419,  # VWN3, used by Gaussian
    'REVB3LYP'      : 'REVB3LYP5',  # VWN5 version
    'REVB3LYP5'     : '.2*HF + .13*SLATER + .67*B88, .84*LYP + .16*VWN',
    'REVB3LYPG'     : 454,  # VWN3, used by Gaussian
    'X3LYP'         : 'X3LYP5',  # VWN5 version
    'X3LYP5'        : '.218*HF + .073*SLATER + .542385*B88 + .166615*PW91, .871*LYP + .129*VWN',
    'X3LYPG'        : 411,  # VWN3, used by Gaussian
    'CAMB3LYP'      : 'HYB_GGA_XC_CAM_B3LYP',
    'CAMYBLYP'      : 'HYB_GGA_XC_CAMY_BLYP',
    'CAMYB3LYP'     : 'HYB_GGA_XC_CAMY_B3LYP',
    'B5050LYP'      : '.5*HF + .08*SLATER + .42*B88, .81*LYP + .19*VWN',
    'MPW1LYP'       : '.25*HF + .75*MPW91, LYP',
    'MPW1PBE'       : '.25*HF + .75*MPW91, PBE',
    'PBE50'         : '.5*HF + .5*PBE, PBE',
    'REVPBE0'       : '.25*HF + .75*PBE_R, PBE',
    'B1B95'         : 440,
    'TPSS0'         : '.25*HF + .75*TPSS, TPSS',
})  # noqa: E501

XC_KEYS = set(XC_CODES.keys())

# Some XC functionals have conventional name, like M06-L means M06-L for X
# functional and M06-L for C functional, PBE mean PBE-X plus PBE-C. If the
# conventional name was placed in the XC_CODES, it may lead to recursive
# reference when parsing the xc description.  These names (as exceptions of
# XC_CODES) are listed in XC_ALIAS below and they should be treated as a
# shortcut for XC functional.
XC_ALIAS = {
    # Conventional name : name in XC_CODES
    'BLYP'              : 'B88,LYP',
    'BP86'              : 'B88,P86',
    'PW91'              : 'PW91,PW91',
    'PBE'               : 'PBE,PBE',
    'REVPBE'            : 'PBE_R,PBE',
    'PBESOL'            : 'PBE_SOL,PBE_SOL',
    'PKZB'              : 'PKZB,PKZB',
    'TPSS'              : 'TPSS,TPSS',
    'REVTPSS'           : 'REVTPSS,REVTPSS',
    'SCAN'              : 'SCAN,SCAN',
    'RSCAN'             : 'RSCAN,RSCAN',
    'R2SCAN'            : 'R2SCAN,R2SCAN',
    'SCANL'             : 'SCANL,SCANL',
    'R2SCANL'           : 'R2SCANL,R2SCANL',
    'SOGGA'             : 'SOGGA,PBE',
    'BLOC'              : 'BLOC,TPSSLOC',
    'OLYP'              : 'OPTX,LYP',
    'OPBE'              : 'OPTX,PBE',
    'RPBE'              : 'RPBE,PBE',
    'BPBE'              : 'B88,PBE',
    'MPW91'             : 'MPW91,PW91',
    'HFLYP'             : 'HF,LYP',
    'HFPW92'            : 'HF,PW_MOD',
    'SPW92'             : 'SLATER,PW_MOD',
    'SVWN'              : 'SLATER,VWN',
    'MS0'               : 'MS0,REGTPSS',
    'MS1'               : 'MS1,REGTPSS',
    'MS2'               : 'MS2,REGTPSS',
    'MS2H'              : 'MS2H,REGTPSS',
    'MVS'               : 'MVS,REGTPSS',
    'MVSH'              : 'MVSH,REGTPSS',
    'SOGGA11'           : 'SOGGA11,SOGGA11',
    'SOGGA11_X'         : 'SOGGA11_X,SOGGA11_X',
    'KT1'               : 'KT1,VWN',
    'KT2'               : 'GGA_XC_KT2',
    'KT3'               : 'GGA_XC_KT3',
    'DLDF'              : 'DLDF,DLDF',
    'GAM'               : 'GAM,GAM',
    'M06_L'             : 'M06_L,M06_L',
    'M06_SX'            : 'M06_SX,M06_SX',
    'M11_L'             : 'M11_L,M11_L',
    'MN12_L'            : 'MN12_L,MN12_L',
    'MN15_L'            : 'MN15_L,MN15_L',
    'N12'               : 'N12,N12',
    'N12_SX'            : 'N12_SX,N12_SX',
    'MN12_SX'           : 'MN12_SX,MN12_SX',
    'MN15'              : 'MN15,MN15',
    'MBEEF'             : 'MBEEF,PBE_SOL',
    'SCAN0'             : 'SCAN0,SCAN',
    'PBEOP'             : 'PBE,OP_PBE',
    'BOP'               : 'B88,OP_B88',
    # new in libxc-4.2.3
    'REVSCAN'           : 'MGGA_X_REVSCAN,MGGA_C_REVSCAN',
    'REVSCAN_VV10'      : 'MGGA_X_REVSCAN,MGGA_C_REVSCAN_VV10',
    'SCAN_VV10'         : 'MGGA_X_SCAN,MGGA_C_SCAN_VV10',
    'SCAN_RVV10'        : 'MGGA_X_SCAN,MGGA_C_SCAN_RVV10',
    'M05'               : 'HYB_MGGA_X_M05,MGGA_C_M05',
    'M06'               : 'HYB_MGGA_X_M06,MGGA_C_M06',
    'M05_2X'            : 'HYB_MGGA_X_M05_2X,MGGA_C_M05_2X',
    'M06_2X'            : 'HYB_MGGA_X_M06_2X,MGGA_C_M06_2X',
    # extra aliases
    'SOGGA11X'          : 'SOGGA11_X',
    'M06L'              : 'M06_L',
    'M11L'              : 'M11_L',
    'MN12L'             : 'MN12_L',
    'MN15L'             : 'MN15_L',
    'N12SX'             : 'N12_SX',
    'MN12SX'            : 'MN12_SX',
    'M052X'             : 'M05_2X',
    'M062X'             : 'M06_2X',
}  # noqa: E122
XC_ALIAS.update([(key.replace('-',''), XC_ALIAS[key])
                 for key in XC_ALIAS if '-' in key])

VV10_XC = set(('B97M_V', 'WB97M_V', 'WB97X_V', 'VV10', 'LC_VV10',
               'REVSCAN_VV10',
               'SCAN_VV10', 'SCAN_RVV10', 'SCANL_VV10', 'SCANL_RVV10'))
VV10_XC = VV10_XC.union(set([x.replace('_', '') for x in VV10_XC]))

def xc_reference(xc_code):
    '''Returns the reference to the individual XC functional'''
    hyb, fn_facs = parse_xc(xc_code)
    refs = []
    c_refs = (ctypes.c_char_p * 8)()
    for xid, fac in fn_facs:
        _itrf.LIBXC_xc_reference(xid, c_refs)
        for ref in c_refs:
            if ref:
                refs.append(ref.decode("UTF-8"))
    return refs

def xc_type(xc_code):
    if xc_code is None:
        return None
    elif isinstance(xc_code, str):
        if is_nlc(xc_code):
            return 'NLC'
        hyb, fn_facs = parse_xc(xc_code)
    else:
        fn_facs = [(xc_code, 1)]  # mimic fn_facs
    if not fn_facs:
        return 'HF'
    elif all(_itrf.LIBXC_is_lda(ctypes.c_int(xid)) for xid, fac in fn_facs):
        return 'LDA'
    elif any(_itrf.LIBXC_is_meta_gga(ctypes.c_int(xid)) for xid, fac in fn_facs):
        return 'MGGA'
    else:
        # any(_itrf.LIBXC_is_gga(ctypes.c_int(xid)) for xid, fac in fn_facs)
        # include hybrid_xc
        return 'GGA'

def is_lda(xc_code):
    return xc_type(xc_code) == 'LDA'

def is_hybrid_xc(xc_code):
    if xc_code is None:
        return False
    elif isinstance(xc_code, str):
        if xc_code.isdigit():
            return _itrf.LIBXC_is_hybrid(ctypes.c_int(int(xc_code)))
        else:
            if 'HF' in xc_code:
                return True
            if hybrid_coeff(xc_code) != 0:
                return True
            if rsh_coeff(xc_code) != [0, 0, 0]:
                return True
            return False
    elif isinstance(xc_code, int):
        return _itrf.LIBXC_is_hybrid(ctypes.c_int(xc_code))
    else:
        return any((is_hybrid_xc(x) for x in xc_code))

def is_meta_gga(xc_code):
    return xc_type(xc_code) == 'MGGA'

def is_gga(xc_code):
    return xc_type(xc_code) == 'GGA'

def needs_laplacian(xc_code):
    return _itrf.LIBXC_needs_laplacian(xc_code) != 0

def is_nlc(xc_code):
    return '__VV10' in xc_code.upper()

def max_deriv_order(xc_code):
    hyb, fn_facs = parse_xc(xc_code)
    if fn_facs:
        return min(_itrf.LIBXC_max_deriv_order(ctypes.c_int(xid)) for xid, fac in fn_facs)
    else:
        return 3

def test_deriv_order(xc_code, deriv, raise_error=False):
    support = deriv <= max_deriv_order(xc_code)
    if not support and raise_error:
        from pyscf.dft import xcfun
        msg = ('libxc library does not support derivative order %d for  %s' %
               (deriv, xc_code))
        try:
            if xcfun.test_deriv_order(xc_code, deriv, raise_error=False):
                msg += ('''
    This functional derivative is supported in the xcfun library.
    The following code can be used to change the libxc library to xcfun library:

        from pyscf.dft import xcfun
        mf._numint.libxc = xcfun
''')
            raise NotImplementedError(msg)
        except KeyError as e:
            sys.stderr.write('\n'+msg+'\n')
            sys.stderr.write('%s not found in xcfun library\n\n' % xc_code)
            raise e
    return support

def hybrid_coeff(xc_code, spin=0):
    '''Support recursively defining hybrid functional
    '''
    hyb, fn_facs = parse_xc(xc_code)
    for xid, fac in fn_facs:
        hyb[0] += fac * _itrf.LIBXC_hybrid_coeff(ctypes.c_int(xid))
    return hyb[0]

def nlc_coeff(xc_code):
    '''Get NLC coefficients
    '''
    nlc_code = None
    if isinstance(xc_code, str) and '__VV10' in xc_code.upper():
        xc_code, nlc_code = xc_code.upper().split('__', 1)

    hyb, fn_facs = parse_xc(xc_code)
    nlc_pars = [0, 0]
    nlc_tmp = (ctypes.c_double*2)()
    for xid, fac in fn_facs:
        _itrf.LIBXC_nlc_coeff(xid, nlc_tmp)
        nlc_pars[0] += nlc_tmp[0]
        nlc_pars[1] += nlc_tmp[1]

    if nlc_pars[0] == 0 and nlc_pars[1] == 0:
        if nlc_code is not None:
            # Use VV10 NLC parameters by default for the general case
            _itrf.LIBXC_nlc_coeff(XC_CODES['GGA_XC_' + nlc_code], nlc_tmp)
            nlc_pars[0] += nlc_tmp[0]
            nlc_pars[1] += nlc_tmp[1]
        else:
            raise NotImplementedError(
                '%s does not have NLC part. Available functionals are %s' %
                (xc_code, ', '.join(VV10_XC.keys())))
    return nlc_pars

def rsh_coeff(xc_code):
    '''Range-separated parameter and HF exchange components: omega, alpha, beta

    Exc_RSH = c_LR * LR_HFX + c_SR * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec
            = alpha * HFX   + beta * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec
            = alpha * LR_HFX + hyb * SR_HFX + (1-c_SR) * Ex_SR + (1-c_LR) * Ex_LR + Ec

    SR_HFX = < pi | e^{-omega r_{12}}/r_{12} | iq >
    LR_HFX = < pi | (1-e^{-omega r_{12}})/r_{12} | iq >
    alpha = c_LR
    beta = c_SR - c_LR = hyb - alpha
    '''
    if xc_code is None:
        return 0, 0, 0

    check_omega = True
    if isinstance(xc_code, str) and ',' in xc_code:
        # Parse only X part for the RSH coefficients.  This is to handle
        # exceptions for C functionals such as M11.
        xc_code = format_xc_code(xc_code)
        xc_code = xc_code.split(',')[0] + ','
        if 'SR_HF' in xc_code or 'LR_HF' in xc_code or 'RSH(' in xc_code:
            check_omega = False

    hyb, fn_facs = parse_xc(xc_code)

    hyb, alpha, omega = hyb
    beta = hyb - alpha
    rsh_pars = [omega, alpha, beta]
    rsh_tmp = (ctypes.c_double*3)()
    _itrf.LIBXC_rsh_coeff(433, rsh_tmp)
    for xid, fac in fn_facs:
        _itrf.LIBXC_rsh_coeff(xid, rsh_tmp)
        if rsh_pars[0] == 0:
            rsh_pars[0] = rsh_tmp[0]
        elif check_omega:
            # Check functional is actually a CAM functional
            if rsh_tmp[0] != 0 and not _itrf.LIBXC_is_cam_rsh(ctypes.c_int(xid)):
                raise KeyError('Libxc functional %i employs a range separation '
                               'kernel that is not supported in PySCF' % xid)
            # Check omega
            if (rsh_tmp[0] != 0 and rsh_pars[0] != rsh_tmp[0]):
                raise ValueError('Different values of omega found for RSH functionals')
        rsh_pars[1] += rsh_tmp[1] * fac
        rsh_pars[2] += rsh_tmp[2] * fac
    return rsh_pars

def parse_xc_name(xc_name='LDA,VWN'):
    '''Convert the XC functional name to libxc library internal ID.
    '''
    fn_facs = parse_xc(xc_name)[1]
    return fn_facs[0][0], fn_facs[1][0]

def parse_xc(description):
    r'''Rules to input functional description:

    * The given functional description must be a one-line string.
    * The functional description is case-insensitive.
    * The functional description string has two parts, separated by ",".  The
      first part describes the exchange functional, the second is the correlation
      functional.

      - If "," was not in string, the entire string is considered as a
        compound XC functional (including both X and C functionals, such as b3lyp).
      - To input only X functional (without C functional), leave the second
        part blank. E.g. description='slater,' means pure LDA functional.
      - To neglect X functional (just apply C functional), leave the first
        part blank. E.g. description=',vwn' means pure VWN functional.
      - If compound XC functional is specified, no matter whehter it is in the
        X part (the string in front of comma) or the C part (the string behind
        comma), both X and C functionals of the compound XC functional will be
        used.

    * The functional name can be placed in arbitrary order.  Two name needs to
      be separated by operators "+" or "-".  Blank spaces are ignored.
      NOTE the parser only reads operators "+" "-" "*".  / is not in support.
    * A functional name can have at most one factor.  If the factor is not
      given, it is set to 1.  Compound functional can be scaled as a unit. For
      example '0.5*b3lyp' is equivalent to
      'HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN'
    * String "HF" stands for exact exchange (HF K matrix).  Putting "HF" in
      correlation functional part is the same to putting "HF" in exchange
      part.
    * String "RSH" means range-separated operator. Its format is
      RSH(omega, alpha, beta).  Another way to input RSH is to use keywords
      SR_HF and LR_HF: "SR_HF(0.1) * alpha_plus_beta" and "LR_HF(0.1) *
      alpha" where the number in parenthesis is the value of omega.
    * Be careful with the libxc convention on GGA functional, in which the LDA
      contribution has been included.

    Args:
        xc_code : str
            A string to describe the linear combination of different XC functionals.
            The X and C functional are separated by comma like '.8*LDA+.2*B86,VWN'.
            If "HF" was appeared in the string, it stands for the exact exchange.
        rho : ndarray
            Shape of ((*,N)) for electron density (and derivatives) if spin = 0;
            Shape of ((*,N),(*,N)) for alpha/beta electron density (and derivatives) if spin > 0;
            where N is number of grids.
            rho (*,N) are ordered as (den,grad_x,grad_y,grad_z,laplacian,tau)
            where grad_x = d/dx den, laplacian = \nabla^2 den, tau = 1/2(\nabla f)^2
            In spin unrestricted case,
            rho is ((den_u,grad_xu,grad_yu,grad_zu,laplacian_u,tau_u)
                    (den_d,grad_xd,grad_yd,grad_zd,laplacian_d,tau_d))

    Kwargs:
        spin : int
            spin polarized if spin > 0
        relativity : int
            No effects.
        verbose : int or object of :class:`Logger`
            No effects.

    Returns:
        ex, vxc, fxc, kxc

        where

        * vxc = (vrho, vsigma, vlapl, vtau) for restricted case

        * vxc for unrestricted case
          | vrho[:,2]   = (u, d)
          | vsigma[:,3] = (uu, ud, dd)
          | vlapl[:,2]  = (u, d)
          | vtau[:,2]   = (u, d)

        * fxc for restricted case:
          (v2rho2, v2rhosigma, v2sigma2, v2lapl2, vtau2, v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)

        * fxc for unrestricted case:
          | v2rho2[:,3]     = (u_u, u_d, d_d)
          | v2rhosigma[:,6] = (u_uu, u_ud, u_dd, d_uu, d_ud, d_dd)
          | v2sigma2[:,6]   = (uu_uu, uu_ud, uu_dd, ud_ud, ud_dd, dd_dd)
          | v2lapl2[:,3]
          | vtau2[:,3]
          | v2rholapl[:,4]
          | v2rhotau[:,4]
          | v2lapltau[:,4]
          | v2sigmalapl[:,6]
          | v2sigmatau[:,6]

        * kxc for restricted case:
          v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3,
          v3rho2tau, v3rhosigmatau, v3rhotau2, v3sigma2tau, v3sigmatau2, v3tau3

        * kxc for unrestricted case:
          | v3rho3[:,4]       = (u_u_u, u_u_d, u_d_d, d_d_d)
          | v3rho2sigma[:,9]  = (u_u_uu, u_u_ud, u_u_dd, u_d_uu, u_d_ud, u_d_dd, d_d_uu, d_d_ud, d_d_dd)
          | v3rhosigma2[:,12] = (u_uu_uu, u_uu_ud, u_uu_dd, u_ud_ud, u_ud_dd, u_dd_dd, d_uu_uu, d_uu_ud, d_uu_dd, d_ud_ud, d_ud_dd, d_dd_dd)
          | v3sigma3[:,10]     = (uu_uu_uu, uu_uu_ud, uu_uu_dd, uu_ud_ud, uu_ud_dd, uu_dd_dd, ud_ud_ud, ud_ud_dd, ud_dd_dd, dd_dd_dd)
          | v3rho2tau
          | v3rhosigmatau
          | v3rhotau2
          | v3sigma2tau
          | v3sigmatau2
          | v3tau3

        see also libxc_itrf.c
    '''  # noqa: E501
    hyb = [0, 0, 0]  # hybrid, alpha, omega (== SR_HF, LR_HF, omega)
    if description is None:
        return hyb, []
    elif isinstance(description, int):
        return hyb, [(description, 1.)]
    elif not isinstance(description, str): #isinstance(description, (tuple,list)):
        return parse_xc('%s,%s' % tuple(description))

    def assign_omega(omega, hyb_or_sr, lr=0):
        if hyb[2] == omega or omega == 0:
            hyb[0] += hyb_or_sr
            hyb[1] += lr
        elif hyb[2] == 0:
            hyb[0] += hyb_or_sr
            hyb[1] += lr
            hyb[2] = omega
        else:
            raise ValueError('Different values of omega found for RSH functionals')
    fn_facs = []

    def parse_token(token, ftype, search_xc_alias=False):
        if token:
            if token[0] == '-':
                sign = -1
                token = token[1:]
            else:
                sign = 1
            if '*' in token:
                fac, key = token.split('*')
                if fac[0].isalpha():
                    fac, key = key, fac
                fac = sign * float(fac)
            else:
                fac, key = sign, token

            if key[:3] == 'RSH':
                # RSH(alpha; beta; omega): Range-separated-hybrid functional
                # See also utils.format_xc_code
                alpha, beta, omega = [float(x) for x in key[4:-1].split(';')]
                assign_omega(omega, fac*(alpha+beta), fac*alpha)
            elif key == 'HF':
                hyb[0] += fac
                hyb[1] += fac  # also add to LR_HF
            elif 'SR_HF' in key:
                if '(' in key:
                    omega = float(key.split('(')[1].split(')')[0])
                    assign_omega(omega, fac, 0)
                else:  # Assuming this omega the same to the existing omega
                    hyb[0] += fac
            elif 'LR_HF' in key:
                if '(' in key:
                    omega = float(key.split('(')[1].split(')')[0])
                    assign_omega(omega, 0, fac)
                else:
                    hyb[1] += fac  # == alpha
            elif key.isdigit():
                fn_facs.append((int(key), fac))
            else:
                if search_xc_alias and key in XC_ALIAS:
                    x_id = XC_ALIAS[key]
                elif key in XC_CODES:
                    x_id = XC_CODES[key]
                else:
                    possible_xc_for = fpossible_dic[ftype]
                    possible_xc = XC_KEYS.intersection(possible_xc_for(key))
                    if possible_xc:
                        if len(possible_xc) > 1:
                            sys.stderr.write('Possible xc_code %s matches %s. '
                                             % (list(possible_xc), key))
                            for x_id in possible_xc:  # Prefer X functional
                                if '_X_' in x_id:
                                    break
                            else:
                                x_id = possible_xc.pop()
                            sys.stderr.write('XC parser takes %s\n' % x_id)
                            sys.stderr.write('You can add prefix to %s for a '
                                             'specific functional (e.g. X_%s, '
                                             'HYB_MGGA_X_%s)\n'
                                             % (key, key, key))
                        else:
                            x_id = possible_xc.pop()
                        x_id = XC_CODES[x_id]
                    else:
                        raise KeyError('Unknown %s functional  %s' % (ftype, key))
                if isinstance(x_id, str):
                    hyb1, fn_facs1 = parse_xc(x_id)
# Recursively scale the composed functional, to support e.g. '0.5*b3lyp'
                    if hyb1[0] != 0 or hyb1[1] != 0:
                        assign_omega(hyb1[2], hyb1[0]*fac, hyb1[1]*fac)
                    fn_facs.extend([(xid, c*fac) for xid, c in fn_facs1])
                elif x_id is None:
                    raise NotImplementedError('%s functional %s' % (ftype, key))
                else:
                    fn_facs.append((x_id, fac))
    def possible_x_for(key):
        return set((key,
                    'LDA_X_'+key, 'GGA_X_'+key, 'MGGA_X_'+key,
                    'HYB_GGA_X_'+key, 'HYB_MGGA_X_'+key))
    def possible_xc_for(key):
        return set((key, 'LDA_XC_'+key, 'GGA_XC_'+key, 'MGGA_XC_'+key,
                    'HYB_GGA_XC_'+key, 'HYB_MGGA_XC_'+key))
    def possible_k_for(key):
        return set((key,
                    'LDA_K_'+key, 'GGA_K_'+key,))
    def possible_x_k_for(key):
        return possible_x_for(key).union(possible_k_for(key))
    def possible_c_for(key):
        return set((key,
                    'LDA_C_'+key, 'GGA_C_'+key, 'MGGA_C_'+key))
    fpossible_dic = {'X': possible_x_for,
                     'C': possible_c_for,
                     'compound XC': possible_xc_for,
                     'K': possible_k_for,
                     'X or K': possible_x_k_for}

    description = format_xc_code(description)

    if '-' in description:  # To handle e.g. M06-L
        for key in _NAME_WITH_DASH:
            if key in description:
                description = description.replace(key, _NAME_WITH_DASH[key])

    if ',' in description:
        x_code, c_code = description.split(',')
        for token in x_code.replace('-', '+-').replace(';+', ';').split('+'):
            parse_token(token, 'X or K')
        for token in c_code.replace('-', '+-').replace(';+', ';').split('+'):
            parse_token(token, 'C')
    else:
        for token in description.replace('-', '+-').replace(';+', ';').split('+'):
            parse_token(token, 'compound XC', search_xc_alias=True)
    if hyb[2] == 0: # No omega is assigned. LR_HF is 0 for normal Coulomb operator
        hyb[1] = 0
    return hyb, remove_dup(fn_facs)

_NAME_WITH_DASH = {'SR-HF'    : 'SR_HF',
                   'LR-HF'    : 'LR_HF',
                   'OTPSS-D'  : 'OTPSS_D',
                   'B97-1'    : 'B97_1',
                   'B97-2'    : 'B97_2',
                   'B97-3'    : 'B97_3',
                   'B97-K'    : 'B97_K',
                   'B97-D'    : 'B97_D',
                   'HCTH-93'  : 'HCTH_93',
                   'HCTH-120' : 'HCTH_120',
                   'HCTH-147' : 'HCTH_147',
                   'HCTH-407' : 'HCTH_407',
                   'WB97X-D'  : 'WB97X_D',
                   'WB97X-V'  : 'WB97X_V',
                   'WB97M-V'  : 'WB97M_V',
                   'B97M-V'   : 'B97M_V',
                   'M05-2X'   : 'M05_2X',
                   'M06-L'    : 'M06_L',
                   'M06-HF'   : 'M06_HF',
                   'M06-2X'   : 'M06_2X',
                   'M08-HX'   : 'M08_HX',
                   'M08-SO'   : 'M08_SO',
                   'M11-L'    : 'M11_L',
                   'MN12-L'   : 'MN12_L',
                   'MN15-L'   : 'MN15_L',
                   'MN12-SX'  : 'MN12_SX',
                   'N12-SX'   : 'N12_SX',
                   'LRC-WPBE' : 'LRC_WPBE',
                   'LRC-WPBEH': 'LRC_WPBEH',
                   'LC-VV10'  : 'LC_VV10',
                   'CAM-B3LYP': 'CAM_B3LYP'}


def eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None):
    r'''Interface to call libxc library to evaluate XC functional, potential
    and functional derivatives.

    * The given functional xc_code must be a one-line string.
    * The functional xc_code is case-insensitive.
    * The functional xc_code string has two parts, separated by ",".  The
      first part describes the exchange functional, the second part sets the
      correlation functional.

      - If "," not appeared in string, the entire string is treated as the
        name of a compound functional (containing both the exchange and
        the correlation functional) which was declared in the functional
        aliases list. The full list of functional aliases can be obtained by
        calling the function pyscf.dft.xcfun.XC_ALIAS.keys() .

        If the string was not found in the aliased functional list, it is
        treated as X functional.

      - To input only X functional (without C functional), leave the second
        part blank. E.g. description='slater,' means a functional with LDA
        contribution only.

      - To neglect the contribution of X functional (just apply C functional),
        leave blank in the first part, e.g. description=',vwn' means a
        functional with VWN only.

      - If compound XC functional is specified, no matter whether it is in the
        X part (the string in front of comma) or the C part (the string behind
        comma), both X and C functionals of the compound XC functional will be
        used.

    * The functional name can be placed in arbitrary order.  Two names need to
      be separated by operators "+" or "-".  Blank spaces are ignored.
      NOTE the parser only reads operators "+" "-" "*".  / is not supported.

    * A functional name can have at most one factor.  If the factor is not
      given, it is set to 1.  Compound functional can be scaled as a unit. For
      example '0.5*b3lyp' is equivalent to
      'HF*0.1 + .04*LDA + .36*B88, .405*LYP + .095*VWN'

    * String "HF" stands for exact exchange (HF K matrix).  "HF" can be put in
      the correlation functional part (after comma). Putting "HF" in the
      correlation part is the same to putting "HF" in the exchange part.

    * String "RSH" means range-separated operator. Its format is
      RSH(omega, alpha, beta).  Another way to input RSH is to use keywords
      SR_HF and LR_HF: "SR_HF(0.1) * alpha_plus_beta" and "LR_HF(0.1) *
      alpha" where the number in parenthesis is the value of omega.

    * Be careful with the libxc convention of GGA functional, in which the LDA
      contribution is included.

    Args:
        xc_code : str
            A string to describe the linear combination of different XC functionals.
            The X and C functional are separated by comma like '.8*LDA+.2*B86,VWN'.
            If "HF" (exact exchange) is appeared in the string, the HF part will
            be skipped.  If an empty string "" is given, the returns exc, vxc,...
            will be vectors of zeros.
        rho : ndarray
            Shape of ((*,N)) for electron density (and derivatives) if spin = 0;
            Shape of ((*,N),(*,N)) for alpha/beta electron density (and derivatives) if spin > 0;
            where N is number of grids.
            rho (*,N) are ordered as (den,grad_x,grad_y,grad_z,laplacian,tau)
            where grad_x = d/dx den, laplacian = \nabla^2 den, tau = 1/2(\nabla f)^2
            In spin unrestricted case,
            rho is ((den_u,grad_xu,grad_yu,grad_zu,laplacian_u,tau_u)
                    (den_d,grad_xd,grad_yd,grad_zd,laplacian_d,tau_d))

    Kwargs:
        spin : int
            spin polarized if spin > 0
        relativity : int
            No effects.
        verbose : int or object of :class:`Logger`
            No effects.

    Returns:
        ex, vxc, fxc, kxc

        where

        * vxc = (vrho, vsigma, vlapl, vtau) for restricted case

        * vxc for unrestricted case
          | vrho[:,2]   = (u, d)
          | vsigma[:,3] = (uu, ud, dd)
          | vlapl[:,2]  = (u, d)
          | vtau[:,2]   = (u, d)

        * fxc for restricted case:
          (v2rho2, v2rhosigma, v2sigma2, v2lapl2, vtau2, v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)

        * fxc for unrestricted case:
          | v2rho2[:,3]     = (u_u, u_d, d_d)
          | v2rhosigma[:,6] = (u_uu, u_ud, u_dd, d_uu, d_ud, d_dd)
          | v2sigma2[:,6]   = (uu_uu, uu_ud, uu_dd, ud_ud, ud_dd, dd_dd)
          | v2lapl2[:,3]
          | vtau2[:,3]
          | v2rholapl[:,4]
          | v2rhotau[:,4]
          | v2lapltau[:,4]
          | v2sigmalapl[:,6]
          | v2sigmatau[:,6]

        * kxc for restricted case:
          (v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3)

        * kxc for unrestricted case:
          | v3rho3[:,4]       = (u_u_u, u_u_d, u_d_d, d_d_d)
          | v3rho2sigma[:,9]  = (u_u_uu, u_u_ud, u_u_dd, u_d_uu, u_d_ud, u_d_dd, d_d_uu, d_d_ud, d_d_dd)
          | v3rhosigma2[:,12] = (u_uu_uu, u_uu_ud, u_uu_dd, u_ud_ud, u_ud_dd, u_dd_dd, d_uu_uu, d_uu_ud, d_uu_dd, d_ud_ud, d_ud_dd, d_dd_dd)
          | v3sigma3[:,10]    = (uu_uu_uu, uu_uu_ud, uu_uu_dd, uu_ud_ud, uu_ud_dd, uu_dd_dd, ud_ud_ud, ud_ud_dd, ud_dd_dd, dd_dd_dd)

        see also libxc_itrf.c
    '''  # noqa: E501
    hyb, fn_facs = parse_xc(xc_code)
    if omega is not None:
        hyb[2] = float(omega)
    return _eval_xc(hyb, fn_facs, rho, spin, relativity, deriv, verbose)


def _eval_xc(hyb, fn_facs, rho, spin=0, relativity=0, deriv=1, verbose=None):
    assert(deriv <= 3)
    if spin == 0:
        nspin = 1
        rho_u = rho_d = numpy.asarray(rho, order='C')
    else:
        nspin = 2
        rho_u = numpy.asarray(rho[0], order='C')
        rho_d = numpy.asarray(rho[1], order='C')
    assert(rho_u.dtype == numpy.double)
    assert(rho_d.dtype == numpy.double)

    if rho_u.ndim == 1:
        rho_u = rho_u.reshape(1,-1)
        rho_d = rho_d.reshape(1,-1)
    ngrids = rho_u.shape[1]

    fn_ids = [x[0] for x in fn_facs]
    facs   = [x[1] for x in fn_facs]
    if hyb[2] != 0:
        # Current implementation does not support different omegas for
        # different RSH functionals if there are multiple RSHs
        omega = [hyb[2]] * len(facs)
    else:
        omega = [0] * len(facs)
    fn_ids_set = set(fn_ids)
    if fn_ids_set.intersection(PROBLEMATIC_XC):
        problem_xc = [PROBLEMATIC_XC[k]
                      for k in fn_ids_set.intersection(PROBLEMATIC_XC)]
        warnings.warn('Libxc functionals %s may have discrepancy to xcfun '
                      'library.\n' % problem_xc)

    if any([needs_laplacian(fid) for fid in fn_ids]):
        raise NotImplementedError('laplacian in meta-GGA method')

    n = len(fn_ids)
    if (n == 0 or  # xc_code = '' or xc_code = 'HF', an empty functional
        all((is_lda(x) for x in fn_ids))):
        if spin == 0:
            nvar = 1
        else:
            nvar = 2
    elif any((is_meta_gga(x) for x in fn_ids)):
        if spin == 0:
            nvar = 4
        else:
            nvar = 9
    else:  # GGA
        if spin == 0:
            nvar = 2
        else:
            nvar = 5

    # Check that the density rho has the appropriate shape
    # should it be >= or ==, in test test_xcfun.py, test_vs_libxc_rks
    # the density contain 6 rows independently of the functional
    if nvar == 1 or (nvar ==2 and spin > 0):  # LDA
        for rho_ud in [rho_u, rho_d]:
            assert rho_ud.shape[0] >= 1

    elif nvar == 2 or nvar == 5:  # GGA
        for rho_ud in [rho_u, rho_d]:
            assert rho_ud.shape[0] >= 4

    elif nvar == 4 or nvar == 9:  # MGGA
        for rho_ud in [rho_u, rho_d]:
            assert rho_ud.shape[0] >= 6


    else:
        raise ValueError("Unknow nvar {}".format(nvar))

    outlen = (math.factorial(nvar+deriv) //
              (math.factorial(nvar) * math.factorial(deriv)))
    outbuf = numpy.zeros((outlen,ngrids))

    _itrf.LIBXC_eval_xc(ctypes.c_int(n),
                        (ctypes.c_int*n)(*fn_ids),
                        (ctypes.c_double*n)(*facs),
                        (ctypes.c_double*n)(*omega),
                        ctypes.c_int(nspin),
                        ctypes.c_int(deriv), ctypes.c_int(rho_u.shape[1]),
                        rho_u.ctypes.data_as(ctypes.c_void_p),
                        rho_d.ctypes.data_as(ctypes.c_void_p),
                        outbuf.ctypes.data_as(ctypes.c_void_p))

    exc = outbuf[0]
    vxc = fxc = kxc = None
    if nvar == 1:  # LDA
        if deriv > 0:
            vxc = (outbuf[1], None, None, None)
        if deriv > 1:
            fxc = (outbuf[2],) + (None,)*9
        if deriv > 2:
            kxc = (outbuf[3], None, None, None)
    elif nvar == 2:
        if spin == 0:  # GGA
            if deriv > 0:
                vxc = (outbuf[1], outbuf[2], None, None)
            if deriv > 1:
                fxc = (outbuf[3], outbuf[4], outbuf[5],) + (None,)*7
            if deriv > 2:
                kxc = outbuf[6:10]
        else:  # LDA
            if deriv > 0:
                vxc = (outbuf[1:3].T, None, None, None)
            if deriv > 1:
                fxc = (outbuf[3:6].T,) + (None,)*9
            if deriv > 2:
                kxc = (outbuf[6:10].T, None, None, None)
    elif nvar == 5:  # GGA
        if deriv > 0:
            vxc = (outbuf[1:3].T, outbuf[3:6].T, None, None)
        if deriv > 1:
            fxc = (outbuf[6:9].T, outbuf[9:15].T, outbuf[15:21].T) + (None,)*7
        if deriv > 2:
            kxc = (outbuf[21:25].T, outbuf[25:34].T, outbuf[34:46].T, outbuf[46:56].T)
    elif nvar == 4:  # MGGA
        if deriv > 0:
            vxc = outbuf[1:5]
        if deriv > 1:
            fxc = outbuf[5:15]
        if deriv > 2:
            kxc = outbuf[15:19]
    elif nvar == 9:  # MGGA
        if deriv > 0:
            vxc = (outbuf[1:3].T, outbuf[3:6].T, outbuf[6:8].T, outbuf[8:10].T)
        if deriv > 1:
            fxc = (outbuf[10:13].T, outbuf[13:19].T, outbuf[19:25].T,
                   outbuf[25:28].T, outbuf[28:31].T, outbuf[31:35].T,
                   outbuf[35:39].T, outbuf[39:43].T, outbuf[43:49].T,
                   outbuf[49:55].T)
    return exc, vxc, fxc, kxc


def define_xc_(ni, description, xctype='LDA', hyb=0, rsh=(0,0,0)):
    '''Define XC functional.  See also :func:`eval_xc` for the rules of input description.

    Args:
        ni : an instance of :class:`NumInt`

        description : str
            A string to describe the linear combination of different XC functionals.
            The X and C functional are separated by comma like '.8*LDA+.2*B86,VWN'.
            If "HF" was appeared in the string, it stands for the exact exchange.

    Kwargs:
        xctype : str
            'LDA' or 'GGA' or 'MGGA'
        hyb : float
            hybrid functional coefficient
        rsh : a list of three floats
            coefficients (omega, alpha, beta) for range-separated hybrid functional.
            omega is the exponent factor in attenuated Coulomb operator e^{-omega r_{12}}/r_{12}
            alpha is the coefficient for long-range part, hybrid coefficient
            can be obtained by alpha + beta

    Examples:

    >>> mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz')
    >>> mf = dft.RKS(mol)
    >>> define_xc_(mf._numint, '.2*HF + .08*LDA + .72*B88, .81*LYP + .19*VWN')
    >>> mf.kernel()
    -76.3783361189611
    >>> define_xc_(mf._numint, 'LDA*.08 + .72*B88 + .2*HF, .81*LYP + .19*VWN')
    >>> mf.kernel()
    -76.3783361189611
    >>> def eval_xc(xc_code, rho, *args, **kwargs):
    ...     exc = 0.01 * rho**2
    ...     vrho = 0.01 * 2 * rho
    ...     vxc = (vrho, None, None, None)
    ...     fxc = None  # 2nd order functional derivative
    ...     kxc = None  # 3rd order functional derivative
    ...     return exc, vxc, fxc, kxc
    >>> define_xc_(mf._numint, eval_xc, xctype='LDA')
    >>> mf.kernel()
    48.8525211046668
    '''
    if isinstance(description, str):
        ni.eval_xc = lambda xc_code, rho, *args, **kwargs: \
                eval_xc(description, rho, *args, **kwargs)
        ni.hybrid_coeff = lambda *args, **kwargs: hybrid_coeff(description)
        ni.rsh_coeff = lambda *args: rsh_coeff(description)
        ni._xc_type = lambda *args: xc_type(description)

    elif callable(description):
        ni.eval_xc = description
        ni.hybrid_coeff = lambda *args, **kwargs: hyb
        ni.rsh_coeff = lambda *args, **kwargs: rsh
        ni._xc_type = lambda *args: xctype
    else:
        raise ValueError('Unknown description %s' % description)
    return ni

def define_xc(ni, description, xctype='LDA', hyb=0, rsh=(0,0,0)):
    return define_xc_(copy.copy(ni), description, xctype, hyb, rsh)
define_xc.__doc__ = define_xc_.__doc__
